This is what the JSON looks like:
[{
"pmid": "2",
"name": " MANAGEMENT",
"result": "1",
"properties": [
{
"prop_id": "32",
"prop_name": "Bonneville",
"address": "122 Lakeshore",
"city": "Ripley",
"state": "OH",
"zip": "11454",
"lat": "41.123",
"long": "-85.5034"
}
]
}]
I am trying to parse it with the following Java code in Android:
JSONObject jObj = null; try { jObj = new JSONObject(jsonStr);
// We get weather info (This is an array)
JSONArray jArr = jObj.getJSONArray("properties");
// We use only the first value
//JSONObject JSONWeather = jArr.getJSONObject(0);
JSONObject c = jArr.getJSONObject(0);
String name = c.getString(TAG_NAME);
String email = c.getString(TAG_EMAIL);
String phone = c.getString(TAG_PHONE);
} catch (JSONException e) {
e.printStackTrace();
}
return null;
I am not getting any results though. How can I successfully parse this JSON? I'm using Android Studio.
Also, if there were multiple pieces to the array, how could we make sure each one of them is printed out?