本文整理了Java中org.json.simple.JSONObject.putAll()
方法的一些代码示例,展示了JSONObject.putAll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONObject.putAll()
方法的具体详情如下:
包路径:org.json.simple.JSONObject
类名称:JSONObject
方法名:putAll
暂无
代码示例来源:origin: apache/metron
/**
* Simple merging of metadata by adding the metadata into the message (if mergeMetadata is set to true).
*
* @param message The parsed message (note: prior to the field transformations)
* @param metadata The metadata passed along
* @param mergeMetadata Whether to merge the metadata or not
* @param config The config for the message strategy.
*/
@Override
public void mergeMetadata(JSONObject message, Map<String, Object> metadata, boolean mergeMetadata, Map<String, Object> config) {
if(mergeMetadata) {
message.putAll(metadata);
}
}
代码示例来源:origin: pinterest/secor
jsonValues.put("timestamp", 1467176315L);
JSONObject json = new JSONObject();
json.putAll(jsonValues);
String msg1 = json.toJSONString();
jsonValues.put("data", "XYZ");
jsonValues.put("timestamp", 1467176344L);
json.putAll(jsonValues);
String msg2 = json.toJSONString();
代码示例来源:origin: apache/metron
private static JSONObject join(JSONObject left, JSONObject right) {
JSONObject message = new JSONObject();
message.putAll(left);
message.putAll(right);
List<Object> emptyKeys = new ArrayList<>();
for(Object key : message.keySet()) {
Object value = message.get(key);
if(value == null || value.toString().length() == 0) {
emptyKeys.add(key);
}
}
for(Object o : emptyKeys) {
message.remove(o);
}
return message;
}
代码示例来源:origin: apache/metron
@Override
public JSONObject enrich(CacheKey k) {
String metadata = k.coerceValue(String.class);
JSONObject output = new JSONObject();
LOGGER.debug("=======Looking Up For: {}", metadata);
output.putAll(getCIFObject(metadata));
return output;
}
代码示例来源:origin: rhuss/jolokia
public byte[] getData() {
JSONObject respond = new JSONObject();
respond.put(Payload.TYPE.asKey(), type.toString().toLowerCase());
if (agentDetails != null) {
respond.putAll(agentDetails.toJSONObject());
}
byte[] ret = getBytes(respond.toJSONString());
if (ret.length > MAX_MSG_SIZE) {
throw new IllegalArgumentException("Message to send is larger (" + ret.length + " bytes) than maximum size of " + MAX_MSG_SIZE + " bytes.");
}
return ret;
}
代码示例来源:origin: linkedin/indextank-engine
@SuppressWarnings("unchecked")
private void addResult(JSONArray ja, SearchResult result) {
JSONObject document = new JSONObject();
document.putAll(result.getFields());
document.put("docid", result.getDocId());
document.put("query_relevance_score", result.getScore());
for(Entry<Integer, Double> entry: result.getVariables().entrySet()) {
document.put("variable_" + entry.getKey(), entry.getValue());
}
for(Entry<String, String> entry: result.getCategories().entrySet()) {
document.put("category_" + entry.getKey(), entry.getValue());
}
ja.add(document);
}
代码示例来源:origin: apache/metron
@Override
public JSONObject joinMessages(Map<String, Tuple> streamMessageMap, MessageGetStrategy messageGetStrategy) {
JSONObject message = new JSONObject();
for (String key : streamMessageMap.keySet()) {
Tuple tuple = streamMessageMap.get(key);
JSONObject obj = (JSONObject) messageGetStrategy.get(tuple);
message.putAll(obj);
}
List<Object> emptyKeys = new ArrayList<>();
for(Object key : message.keySet()) {
Object value = message.get(key);
if(value == null || value.toString().length() == 0) {
emptyKeys.add(key);
}
}
for(Object o : emptyKeys) {
message.remove(o);
}
message.put(getClass().getSimpleName().toLowerCase() + ".joiner.ts", "" + System.currentTimeMillis());
return message;
}
代码示例来源:origin: apache/metron
gm.captures();
JSONObject message = new JSONObject();
message.putAll(gm.toMap());
代码示例来源:origin: apache/metron
gm.captures();
JSONObject message = new JSONObject();
message.putAll(gm.toMap());
代码示例来源:origin: apache/metron
} catch (Throwable e) {
JSONObject errorMessage = new JSONObject();
errorMessage.putAll(m);
errorMessage.put(Constants.SENSOR_TYPE, sensorType );
errors.add(new AbstractMap.SimpleEntry<>(errorMessage, new IllegalStateException(strategy + " error with " + task.getKey() + " failed: " + e.getMessage(), e)));
代码示例来源:origin: apache/metron
parsedJson.putAll(extractHeaderFields(originalMessage));
parsedJson.putAll(parse(originalMessage));
parsedJson.put(Constants.Fields.ORIGINAL.getName(), originalMessage);
代码示例来源:origin: chatty/chatty
/**
* Encodes the given Map of parameters to a JSON String.
*
* @param parameters The Map of parsed parameters
* @return The JSON String
*/
private static String encodeParametersToJSON(Map<String, String> parameters) {
JSONObject object = new JSONObject();
object.putAll(parameters);
return object.toJSONString();
}
代码示例来源:origin: com.github.martinpaljak/apdu4j
@Override
@SuppressWarnings("unchecked")
public synchronized void send(Map<String, Object> msg) throws IOException {
JSONObject obj = new JSONObject();
obj.putAll(msg);
byte[] data = obj.toJSONString().getBytes(Charset.forName("UTF-8"));
socket.getOutputStream().write(length.putInt(0, data.length).array());
socket.getOutputStream().write(data);
logger.debug("> ({}) {}", HexUtils.bin2hex(length.array()), obj.toJSONString());
}
代码示例来源:origin: martinpaljak/apdu4j
@Override
@SuppressWarnings("unchecked")
public synchronized void send(Map<String, Object> msg) throws IOException {
JSONObject obj = new JSONObject();
obj.putAll(msg);
byte[] data = obj.toJSONString().getBytes(Charset.forName("UTF-8"));
socket.getOutputStream().write(length.putInt(0, data.length).array());
socket.getOutputStream().write(data);
logger.debug("> ({}) {}", HexUtils.bin2hex(length.array()), obj.toJSONString());
}
代码示例来源:origin: jsevellec/cassandra-unit
@Override
public void print(T data, PrintStream out)
{
JSONObject json = new JSONObject();
json.putAll(data.convert2Map());
out.println(json.toString());
}
}
代码示例来源:origin: org.apache.cassandra/cassandra-all
@Override
public void print(T data, PrintStream out)
{
JSONObject json = new JSONObject();
json.putAll(data.convert2Map());
out.println(json.toString());
}
}
代码示例来源:origin: com.strapdata.cassandra/cassandra-all
@Override
public void print(T data, PrintStream out)
{
JSONObject json = new JSONObject();
json.putAll(data.convert2Map());
out.println(json.toString());
}
}
代码示例来源:origin: org.jolokia/jolokia-core
public byte[] getData() {
JSONObject respond = new JSONObject();
respond.put(Payload.TYPE.asKey(), type.toString().toLowerCase());
if (agentDetails != null) {
respond.putAll(agentDetails.toJSONObject());
}
byte[] ret = getBytes(respond.toJSONString());
if (ret.length > MAX_MSG_SIZE) {
throw new IllegalArgumentException("Message to send is larger (" + ret.length + " bytes) than maximum size of " + MAX_MSG_SIZE + " bytes.");
}
return ret;
}
代码示例来源:origin: org.jolokia/jolokia-osgi
public byte[] getData() {
JSONObject respond = new JSONObject();
respond.put(Payload.TYPE.asKey(), type.toString().toLowerCase());
if (agentDetails != null) {
respond.putAll(agentDetails.toJSONObject());
}
byte[] ret = getBytes(respond.toJSONString());
if (ret.length > MAX_MSG_SIZE) {
throw new IllegalArgumentException("Message to send is larger (" + ret.length + " bytes) than maximum size of " + MAX_MSG_SIZE + " bytes.");
}
return ret;
}
代码示例来源:origin: org.jolokia/jolokia-server-core
/** {@inheritDoc} */
public JSONObject toJSON() {
JSONObject ret = super.toJSON();
JSONObject commandJson = command.toJSON();
ret.putAll(commandJson);
return ret;
}
内容来源于网络,如有侵权,请联系作者删除!