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

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -