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()

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi阅读 7,490评论 0 10
  • pyspark.sql模块 模块上下文 Spark SQL和DataFrames的重要类: pyspark.sql...
    mpro阅读 9,546评论 0 13
  • 英文文档,一开始我也是抗拒的,边翻译边看,也就花费了1个小时基本就阅读过了,我的英文基础其实很差。附上链接:链接:...
    lonecolonel阅读 10,068评论 3 1
  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom阅读 2,735评论 0 3
  • 看中餐厅 一个抱着孩子的妈妈 看到苏有朋哭了 当时的我,眼泪在打转 脑海中都是他们的歌声 我快速打开QQ音乐 搜索...
    我是Melody阅读 650评论 0 0