I have a JsonObject and I need to add new values to it. The values are Strings. There is a method available JsonObject.put(), which takes two variables:
StringKey.JsonValuevalue.
How to convert the String, which is in the JSON format, to JsonValue so that I can add it to the JsonObject?
Advertisement
Answer
this:
JSONObject j=new JSONObject();
JSONObject j2=new JSONObject();
j2.put("XXX", "UUU");
j.put("one key", "one value");
j.put("2", j2);