java生成json格式日志存到 mongodb

1. json-lib-2.3-jdk15.jar  :  package net.sf.json;


no function to return a json object from a direct string , but allows json.putAll(Map/JSON) to combine jsons. just like map.putAll().

using this class, you should new JSONObject and then use put() to give values to these objects, this would take time for our java code.

2. json-20090211_1.jar has one more function than JSONModule-1.0.7.0.jar
  when constructing a json object.    package org.json;

allows to return a json object using a string .  new JSONObject(String str).

it is good to save time transferring from string to Object, consider String to Map, which we used our own java code before.

So we may use this class since map.putAll() could be used to relace #1.

using above class, you need ways to combine two json.

3. Finally, we should use the org.json packages !

最后发现 JSONObject jsonOne = new JSONObject(json1);
jsonThree.putAll(jsonTwo);

不是在同一类json框架中。

决定使用json lib :  public static JSONObject fromObject(Object object, JsonConfig jsonConfig)  和 json.putAll()

你可能感兴趣的:(java生成json格式日志存到 mongodb)