java - how to get json value in android -
java - how to get json value in android -
i read many illustration , seek it. didn't work value.
the result returned whole json me.
i don't know wrong...
this first time inquire question. help.
here json , java code.
json:`
{ "food":{ "name":"xxx food", "details":{ "code":"01", "location":{ "area":"area d", "place":"food" }, "price":"132.21", "discount":"15%" } } }
now, want price.
java code:
jsonobject json = new jsonobject(recvstr); jsonarray results = json.getjsonarray("food"); jsonarray msg = results.getjsonarray(0); result = msg.getjsonobject(0).getstring("price");
results
not jsonarray
jsonobject
:
jsonobject results = json.getjsonobject("food"); string name = results.getstring("name"); jsonobject details = results.getjsonobject("details"); string cost = details.getstring("price");
you can read more json @ json.org.
java android json
Comments
Post a Comment