-4

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!

CCCCoder3
  • 39
  • 3
  • Does this answer your question? [How do I parse JSON objects from a JSONArray?](https://stackoverflow.com/questions/47436239/how-do-i-parse-json-objects-from-a-jsonarray) – Savior Apr 28 '20 at 17:46
  • Also https://stackoverflow.com/questions/36805754/can-we-convert-a-string-to-json-array-using-the-json-simple-1-1-1-jar-library – Savior Apr 28 '20 at 17:52

1 Answers1

-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") 
Kapstok
  • 9
  • 2