本文整理了Java中org.json.JSONObject.putAll()
方法的一些代码示例,展示了JSONObject.putAll()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JSONObject.putAll()
方法的具体详情如下:
包路径:org.json.JSONObject
类名称:JSONObject
方法名:putAll
暂无
代码示例来源:origin: loklak/loklak_server
/**
* Return a copy of the JSON content
* @return JSONObject json
*/
public synchronized JSONObject toJSONObject(){
JSONObject res = new JSONObject();
res.putAll(this);
return res;
}
代码示例来源:origin: stackoverflow.com
Map<String, Object> data = new HashMap<String, Object>();
data.put( "name", "Mars" );
data.put( "age", 32 );
data.put( "city", "NY" );
JSONObject json = new JSONObject();
json.putAll( data );
System.out.printf( "JSON: %s", json.toString(2) );
代码示例来源:origin: loklak/loklak_server
/**
* create an campaign with a dumped map
* @param campaignMap
*/
public Campaign(JSONObject campaignMap) {
this();
this.map.putAll(campaignMap);
this.start_time = ((Date) this.map.get("start_date")).getTime();
this.end_time = ((Date) this.map.get("end_date")).getTime();
this.id = DateParser.minuteDateFormat.format((Date) this.map.get("start_date")).replace(' ', '_') + "-" + DateParser.minuteDateFormat.format((Date) this.map.get("end_date")).replace(' ', '_') + "-" + Math.abs(((String) this.map.get("query")).hashCode()) + "-" + Math.abs(((String) this.map.get("name")).hashCode());
}
代码示例来源:origin: loklak/loklak_server
@Override
public synchronized void putAll(JSONObject other){
super.putAll(other);
commit();
}
代码示例来源:origin: loklak/loklak_server
/**
* Merging of data is required during an mind-meld.
* To meld two thoughts, we combine their data arrays into one.
* The resulting table has the maximum length of the source tables
* @param table the information to be melted into our existing table.
* @return the thought
*/
public SusiThought mergeData(JSONArray table1) {
JSONArray table0 = this.getData();
while (table0.length() < table1.length()) table0.put(new JSONObject());
for (int i = 0; i < table1.length(); i++) {
table0.getJSONObject(i).putAll(table1.getJSONObject(i));
}
setData(table0);
return this;
}
代码示例来源:origin: loklak/loklak_server
public static JSONObject testJson(boolean ordered) {
JSONObject json = new JSONObject(ordered);
Map<String, Object> map = new HashMap<>();
map.put("abc", 1);
map.put("def", "Hello World");
map.put("ghj", new String[]{"Hello", "World"});
json.putAll(new JSONObject(map));
json.put("eins", 1);
json.put("zwei", 2);
json.put("drei", 3);
json.put("vier", 4);
json.put("fuenf", 5);
return json;
}
代码示例来源:origin: loklak/loklak_server
private static void setTwitterMetaData(JSONObject metadata, final int startRecord,
final int maximumRecords, TwitterTimeline tl, String query, String filter, Query post, JSONObject hits) {
// the number of the first record (according to SRU set to 1 for very first)
metadata.put("startRecord", startRecord);
// number of records within this json result set returned in the api call
metadata.put("maximumRecords", maximumRecords);
// number of records available in the search cache (so far, may be increased later > hits)
metadata.put("count", tl.size());
// number of records in the search index (so far, may be increased later as well)
metadata.put("hits", tl.getHits());
if (tl.getOrder() == Order.CREATED_AT) metadata.put("period", tl.period());
metadata.put("query", query);
metadata.put("filter", filter);
metadata.put("client", post.getClientHost());
metadata.put("time", System.currentTimeMillis() - post.getAccessTime());
metadata.put("servicereduction", post.isDoS_servicereduction() ? "true" : "false");
metadata.putAll(hits);
String scraperInfo = tl.getScraperInfo() == null ? "" : tl.getScraperInfo();
metadata.put("scraperInfo", scraperInfo);
String index = tl.getResultIndex() == null ? "" : String.valueOf(tl.getResultIndex());
metadata.put("index", index);
}
代码示例来源:origin: loklak/loklak_server
public static JSONObject getNetwork(String screen_name, int maxFollowers, int maxFollowing) throws IOException, TwitterException {
JSONObject map = new JSONObject(true);
map.putAll(getNetworkerNames(screen_name, maxFollowers, Networker.FOLLOWERS));
map.putAll(getNetworkerNames(screen_name, maxFollowing, Networker.FOLLOWING));
map.remove("screen_name");
代码示例来源:origin: loklak/loklak_server
public void init(final JSONObject extmap) throws IOException {
this.json.putAll(extmap);
Date now = new Date();
this.json.put(Field.authentication_first.name(), this.json.has(Field.authentication_first.name()) ? parseDate(this.json.get(Field.authentication_first.name()), now) : now);
this.json.put(Field.authentication_latest.name(), this.json.has(Field.authentication_latest.name()) ? parseDate(this.json.get(Field.authentication_latest.name()), now) : now);
boolean containsAuth = this.json.has(Field.oauth_token.name()) && this.json.has(Field.oauth_token_secret.name());
if (this.json.has(Field.source_type.name())) {
// verify the type
try {
SourceType st = SourceType.byName((String) this.json.get(Field.source_type.name()));
this.json.put(Field.source_type.name(), st.toString());
} catch (IllegalArgumentException e) {
throw new IOException(Field.source_type.name() + " contains unknown type " + (String) this.json.get(Field.source_type.name()));
}
} else {
this.json.put(Field.source_type.name(), SourceType.TWITTER);
}
if (!this.json.has(Field.apps.name()) && !containsAuth) {
throw new IOException("account data must either contain authentication details or an apps setting");
}
}
代码示例来源:origin: loklak/loklak_server
message.putAll(mappedProperties);
代码示例来源:origin: yacy/yacy_grid_mcp
public Contract mergeData(JSONArray table1) {
JSONArray table0 = this.getData();
int t0c = 0;
for (int i = 0; i < table1.length(); i++) {
JSONObject j1i = table1.getJSONObject(i);
while (t0c < table0.length() && anyObjectKeySame(j1i, table0.getJSONObject(t0c))) {t0c++;}
if (t0c >= table0.length()) table0.put(new JSONObject(true));
table0.getJSONObject(t0c).putAll(table1.getJSONObject(i));
}
setData(table0);
return this;
}
代码示例来源:origin: yacy/yacy_grid_mcp
/**
* Merging of data is required during an mind-meld.
* To meld two thoughts, we combine their data arrays into one.
* The resulting table has at maximum the length of both source tables combined.
* @param table the information to be melted into our existing table.
* @return the thought
*/
public SusiThought mergeData(JSONArray table1) {
JSONArray table0 = this.getData();
int t0c = 0;
for (int i = 0; i < table1.length(); i++) {
JSONObject j1i = table1.getJSONObject(i);
while (t0c < table0.length() && anyObjectKeySame(j1i, table0.getJSONObject(t0c))) {t0c++;}
if (t0c >= table0.length()) table0.put(new JSONObject(true));
table0.getJSONObject(t0c).putAll(table1.getJSONObject(i));
}
setData(table0);
return this;
}
代码示例来源:origin: stackoverflow.com
JSONObject mergeJson = new JSONObject();
mergeJson.putAll(jo1);
mergeJson.putAll(jo2);
mergeJson.putAll(jo3);
代码示例来源:origin: stackoverflow.com
JSONObject jsonObject=new JSONObject();
for(LinkedHashMap<String,Object> map:stringObject){
jsonObject.putAll(map);
System.out.println(jsonObject);
}
代码示例来源:origin: stackoverflow.com
JSONObject json = new JSONObject();
json.putAll(WordMap);
String serializedMap = json.toString();
prop.setProperty("wordMap", serializedMap);
代码示例来源:origin: stackoverflow.com
Iterator one = (Iterator) friends.find(query).projection("{_id:0}").as(Object.class);
while (one.hasNext()) {
Map data= new HashMap();
data= (HashMap) one.next();
JSONObject d = new JSONObject();
d.putAll(data);
String content=d.toString();
}
代码示例来源:origin: stackoverflow.com
Map<String, Object> data = new HashMap<String, Object>();
data.put( "name", "Mars" );
data.put( "age", 32 );
data.put( "city", "NY" );
JSONObject json = new JSONObject();
json.putAll( data );
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
response.getWriter().println(json);
代码示例来源:origin: stackoverflow.com
if (object instanceof Map){
JSONObject jsonObject = new JSONObject();
jsonObject.putAll((Map)object);
...
...
}
else if (object instanceof List){
JSONArray jsonArray = new JSONArray();
jsonArray.addAll((List)object);
...
...
}
代码示例来源:origin: stackoverflow.com
if (object instanceof Map){
JSONObject jsonObject = new JSONObject();
jsonObject.putAll((Map)object);
...
...
}
else if (object instanceof List){
JSONArray jsonArray = new JSONArray();
jsonArray.addAll((List)object);
...
...
}
代码示例来源:origin: stackoverflow.com
public JSONArray getJsonObjectOrJsonArray(Object object){
JSONArray jsonArray = new JSONArray();
if (object instanceof Map){
JSONObject jsonObject = new JSONObject();
jsonObject.putAll((Map)object);
jsonArray.add(jsonObject);
}
else if (object instanceof List){
jsonArray.addAll((List)object);
}
return jsonArray;
}
内容来源于网络,如有侵权,请联系作者删除!