0

What im trying to do is

JSON:

{
aKey:{
        aChildKey:""
     },
bKey:""
}

expected:

aKey:{
        aChildKey:"aKey.aChildKey"
     },
bKey:"bKey"
}

Please can some one help me in getting the expected the value

1 Answers1

1

You need to deserialize the JSON into an object, set the values, then serialize it back into JSON. There are a number of libraries you can use for this, like org.json, gson, or Jackson. Those libraries also allow you to modify the value directly. For example, using org.json, you can do something like this:

JSONObject jsonObject = new JSONObject(myJsonString);
jsonObject.getJSONObject("akey").put("aChildKey","aKey.aChildKey");

See How to parse JSON in Java

Tyler Liu
  • 989
  • 1
  • 6
  • 7