1String jsonString = new JSONObject()
2 .put("JSON1", "Hello World!")
3 .put("JSON2", "Hello my World!")
4 .put("JSON3", new JSONObject().put("key1", "value1"))
5 .toString();
6
7System.out.println(jsonString);
8
1String json = Json.createObjectBuilder()
2 .add("key1", "value1")
3 .add("key2", "value2")
4 .build()
5 .toString();
6