hey,
i'm just getting started with using json with java. i'm not sure how to access string values within a JSONArray. for instance, my json looks like this:
{
"locations": {
"record": [
{
"id": 8817,
"loc": "NEW YORK CITY"
},
{
"id": 2873,
"loc": "UNITED STATES"
},
{
"id": 1501,
"loc": "NEW YORK STATE"
}
]
}
my code:
JSONObject req = new JSONObject(join(loadStrings(data.json),""));
JSONObject locs = req.getJSONObject("locations");
JSONArray recs = locs.getJSONArray("record");
i have access to the "record" JSONArray at this point, but am unsure as to how i'd get the "id" and "loc" values within a for loop. sorry if this isn't description isn't too clear, i'm a bit new to programming.