Sample JSON:
{"xyz":{"string":"hello"},"abc":{"string":"rts","event":"file","value":"100"}}
Suppose these are the values present in my JSON file, how do I get the value of the key "event" present in these.
PS: The objects are not separated by commas, and obj in the below code is the object that is created after parsing,
JSONObject jsonObject = (JSONObject) obj;
JSONObject jsonObject1 = (JSONObject) jsonObject.get("abc");
String eventType=(String)jsonObject1.get("event");
This is the code I have used, but I know this is not the optimal solution as the file which I may receive could have objects with other name.
I want to parse all the values in the json file at a time, and get the value, without creating objects for individual records present inside them.