How to fluently build JSON in Java?

后端 未结 9 1067
别跟我提以往
别跟我提以往 2020-12-07 13:43

I\'m thinking of something like:

String json = new JsonBuilder()
  .add(\"key1\", \"value1\")
  .add(\"key2\", \"value2\")
  .add(\"key3\", new JsonBuilder()         


        
9条回答
  •  孤街浪徒
    2020-12-07 14:08

    It sounds like you probably want to get ahold of json-lib:

    http://json-lib.sourceforge.net/

    Douglas Crockford is the guy who invented JSON; his Java library is here:

    http://www.json.org/java/

    It sounds like the folks at json-lib picked up where Crockford left off. Both fully support JSON, both use (compatible, as far as I can tell) JSONObject, JSONArray and JSONFunction constructs.

    'Hope that helps ..

提交回复
热议问题