Trying to use json simple to parse data from rest service. The response looks like:
{
"locations": [
"city" : "San Jose",
"state" : "Ca",
"job" : {
"site" : "Main Processing",
"region" : "USA"
}
]
}
JSONParser jsonParser = new JSONParser();
JSONObject jsonObject = (JSONObject) jsonParser.parse(reader);
JSONArray array = (JSONArray) jsonObject.get("locations");
for(int i = 0; i < array.size(); i++) {
String site = array.getJSONObject(i).getString("site");
}
My issue is I am having trouble getting a reference to the job element from JSONArray object. The "locations" reference is basic parsing but the "job" reference is giving me issue when its defined inside an array.
Also getJSONObject does not seem to be a valid method to JSONArray.
Can this be done with the json-simple library?