Android / Java : Parse Array of JSON coming from Rails -
my server written in rails 4.x , to_json method i'm using return records through api delivering array of json android looks this:
[{"id":503240,"name":"bob"},{"id":503241,"name":"tom"}]
it comes down android fine , have no problems using string , logging it.
now want loop through each item of array grab id (ultimately show on listview).
the first thing need "see" each individual object. parsing above using following line of code:
jsonarray jsonresponse = new jsonarray(jsonstring);
it "parses" no errors, ... when try jsonresponse[1], or jsonresponse.getobject(1) hands on 1 of elements of array (just log example), can't past ide telling me i'm doing wrong.
if can address , manipulate individual json objects, i'm sure i'll have no problems addressing individual data elements. it's arrayness of causing problems.
i'm little new java , i'm spoiled ruby , swift. i'm missing basic. doing wrong?
thanks in advance.
there seems no method getobject
on jsonarray
instances in android. documentation here.
i guess need is:
jsonresponse.getjsonobject(1)
because jsonresponse
array of jsonobject
s
Comments
Post a Comment