Dev Loppeur Dev Loppeur - 1 year ago 76
JSON Question

extract from a multiple json

I have a json like this:


every "sub-json" I want to convert it to Model object.(an object that contains as attributes id value and date).
How can I do it?
Thank you.

Answer Source

You got an array of objects.

JSONArray jsonarray = new JSONArray(jsonStr);
for (int i = 0; i < jsonarray.length(); i++) {
   JSONObject jsonobject = jsonarray.getJSONObject(i);
   String id = jsonobject.getString("id");
   String value = jsonobject.getString("value");
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download