How to parse nested JSON object in android -


i want parse verse_nr , verse bellow json data.can me..

{"book":[{"book_ref":"ps","book_name":"psalms","book_nr":"19","chapter_nr":"16","chapter":{"8":{"verse_nr":"8","verse":"i have set lord before me: because @ right hand, shall not moved."}}}],"direction":"ltr","type":"verse","version":"kjv"} 

you'll need use json parser library. here's example org.json. parser.

jsonobject root = new jsonobject(inputjson);  jsonobject chapter = root.getjsonarray("book")                          .getjsonobject(0).getjsonobject("chapter"); jsonobject verse = chapter.getjsonobject(jsonobject.getnames(chapter)[0]); 

basically, chain json getters till reach verse object. once there, can access values getstring() as

system.out.println(verse.getstring("verse_nr")); system.out.println(verse.getstring("verse")); 

output :

8
have set lord before me: because @ right hand, shall not moved.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -