I have this json structure in a JSONObject:
{
"images":
{
"-KEHe39xfHoRmK9gPxpv":
{
"image": "",
"imei": "000000000000000",
"latitude": "",
"longitude": ""
},
"-KEHe5BOpHz6WlKF_F5B":
{
"image": "",
"imei": "000000000000000",
"latitude": "",
"longitude": ""
},
"-KEHe73aFp59v5Y_mX0Z":
{
"image": "",
"imei": "000000000000000",
"latitude": "",
"longitude": ""
}
}
}
As you can see, the keys are unique. I know that when I do
jsonArray = jsonObject.getJSONArray("images");
... I can get the values of the corresponding key.
My problem is that I don't know the keys. So I can't put them into .getJSONArray() in order to get my values back.
I tried to get the arrays of the arrays
jsonArray = jsonObject.getJSONArray("images").getJSONArray(x); // x == 0 , 1 , 2 , 3
String test = jsonArray.toString();
textView.setText(test);
Gives me this output
04-03 20:41:16.073 9080-9080/com.example.app W/System.err: org.json.JSONException: Value {"-KEHe8nN5iFyGCIXiuv-":{"image":"DATA","longitude":"DATA","latitude":"DATA","imei":"000000000000000"},"-KEHe5BOpHz6WlKF_F5B":{"image":"DATA","longitude":"DATA","latitude":"DATA","imei":"000000000000000"},"-KEHe39xfHoRmK9gPxpv":{"image":"DATA"
04-03 20:41:16.073 9080-9080/com.example.app W/System.err: at org.json.JSON.typeMismatch(JSON.java:100)
04-03 20:41:16.077 9080-9080/com.example.app W/System.err: at org.json.JSONObject.getJSONArray(JSONObject.java:548)
*I replaced the actual data in the output...