Issue
How do I parse this using Volley
{
"ref": "suc",
"contactInfo": {
"name": "Jezzi",
"age": "3",
"Place": "Kochi"
}
}
@Override
public void onResponse(String response) {
try {
JSONObject jsonObject = new JSONObject(response);
String ref = jsonObject.getString("ref");
} catch (Exception e ) {
Log.i("Hello", e.toString);
}
}
I'm getting string value ref, but I don't know how to get the other values.
Solution
I think this might help you:
try {
JSONObject jsonObject = new JSONObject(response);
String ref = jsonObject.getString("ref");
JSONObject contactJsonObject = jsonObject.getJSONObject("contactInfo");
String name = contactJsonObject.getString("name");
// and other values like this
} catch (Exception e ) {
Log.i("Hello", e.toString);
}
Answered By - danial iranpour
Answer Checked By - Cary Denson (JavaFixing Admin)