I have the following JSON:
[{
"aaa": "blah",
"ddd": 2
}]
Note that the map is inside an array. How to get the map and then the value of "aaa".
Using Json Simple.
Thanks!
-
Does this answer your question? How do I parse JSON objects from a JSONArray?Savior– Savior2020年04月28日 17:46:43 +00:00Commented Apr 28, 2020 at 17:46
-
Also stackoverflow.com/questions/36805754/…Savior– Savior2020年04月28日 17:52:43 +00:00Commented Apr 28, 2020 at 17:52
1 Answer 1
The following code should work. Let me know if it doesn't!
Object obj = JSONValue.parse(jsonString);
JSONArray array = (JSONArray)obj;
JSONObject obj2 = (JSONObject)array.get(0);
String result = obj2.get("aaa")
Sign up to request clarification or add additional context in comments.
Comments
lang-java