{
"CustomerDetails": [
{
"AccountName": "test",
"DnBNumber": 12342314
}
]
}
I want to get value from this json object.
I tried below but not working.
jsonObject.getJSONObject("AccountName").toString();
{
"CustomerDetails": [
{
"AccountName": "test",
"DnBNumber": 12342314
}
]
}
I want to get value from this json object.
I tried below but not working.
jsonObject.getJSONObject("AccountName").toString();
In the JSON you put, there are a JsonObject that contains a JsonArray, that contains two String, so..
final JSONObject jsonObject = new JSONObject(YOUR_JSON);
final JSONArray jsonArray = obj.getJSONArray("CustomerDetails");
for (int i = 0; i < geodata.length(); ++i) {
final JSONObject detail = geodata.getJSONObject(i);
System.out.println(detail.getString("AccountName"));
System.out.println(detail.getString("DnBNumber"));
}