I'm trying to display following JSON to my RecyclerView and perform action accordingly. Now, the problem is, How can I access each key from JSON object and values inside keys. Do I need to store them in Java Objects with POJO or Array? I'm getting following response from server so I don't want to store them statically, I want to store it dynamically.
I looked for solution for the same but most of them include JSONArray and my response doesn't include any JSONArray. It includes key and JSONObject as a value. I don't know java as well, I am webdev, I've been looking for it for a day now.
{
"response": {
"status": 200,
"result": {
"17": {
"key1": "3",
"key2": "111111",
"key3": "aaa",
"key4": "sss",
"key5": "aaa@asd.com",
"key6": "1122334455",
"key7": "2017-12-11",
"key7": "something",
"key9": "location"
},
"18": {
"key1": "3",
"key2": "111111",
"key3": "aaa",
"key4": "sss",
"key5": "aaa@asd.com",
"key6": "1122334455",
"key7": "2017-12-11",
"key7": "something",
"key9": "location"
},
"19": {
"key1": "3",
"key2": "111111",
"key3": "aaa",
"key4": "sss",
"key5": "aaa@asd.com",
"key6": "1122334455",
"key7": "2017-12-11",
"key7": "something",
"key9": "location"
}
}
}
}
I have Result JSONObject in a string,
public void onResponse(JSONObject response) {
String status = null;
try {
JSONObject responseCode = response.getJSONObject("response");
status = responseCode.getString("result");
//Todo
} catch (JSONException e) {
e.printStackTrace();
defaultView.setText("Json Error");
}
defaultView.setText(status);
}