Skip to content
Advertisement

Convert String to javax.json.JsonValue

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:

  1. String Key.
  2. JsonValue value.

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);
Advertisement