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 !

最后發(fā)現(xiàn) JSONObject jsonOne = new JSONObject(json1);
jsonThree.putAll(jsonTwo);

不是在同一類json框架中。

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

最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者
平臺聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡書系信息發(fā)布平臺,僅提供信息存儲服務(wù)。

推薦閱讀更多精彩內(nèi)容

  • rljs by sennchi Timeline of History Part One The Cognitiv...
    sennchi閱讀 7,452評論 0 10
  • pyspark.sql模塊 模塊上下文 Spark SQL和DataFrames的重要類: pyspark.sql...
    mpro閱讀 9,513評論 0 13
  • 英文文檔,一開始我也是抗拒的,邊翻譯邊看,也就花費(fèi)了1個(gè)小時(shí)基本就閱讀過了,我的英文基礎(chǔ)其實(shí)很差。附上鏈接:鏈接:...
    lonecolonel閱讀 10,022評論 3 1
  • mean to add the formatted="false" attribute?.[ 46% 47325/...
    ProZoom閱讀 2,727評論 0 3
  • 看中餐廳 一個(gè)抱著孩子的媽媽 看到蘇有朋哭了 當(dāng)時(shí)的我,眼淚在打轉(zhuǎn) 腦海中都是他們的歌聲 我快速打開QQ音樂 搜索...
    我是Melody閱讀 642評論 0 0