Json parsing

22 views
Skip to first unread message

Dilan Wijerathne

unread,
May 26, 2015, 4:04:03 PM5/26/15
to codenameone...@googlegroups.com

my web service gives this jason 

{root=[{"name"=UK Babab huggies, "status"=1, "price"=5652525, "brand"=huggies}, {"name"=boots, "status"=1, "price"=25659, "brand"=boot}]}


I want to get it parse and get each elements, but Unfortunately codename one does not support / work it properly as you have explain in here  


I wrote like this in statemachine class.



JSONParser p = new JSONParser();
 Result result = Result.fromContent(input, Result.JSON);
              String [] values = result.getAsStringArray("//root[1]"); 

but it gives null result 

How can I fix this ?

IDE: NetBeans/
Desktop Windows 
Simulator

Steve Hannah

unread,
May 26, 2015, 4:18:28 PM5/26/15
to codenameone...@googlegroups.com
Your query "//root[1]" looks like it should return the Map {"name"=boots, "status"=1, "price"=25659, "brand"=boot}, so getting it as a String array probably won't work. I would have though it would throw an exception - but null is a possible return value for that also, I guess.

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.
Visit this group at http://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/c0f0c0fe-e88a-4538-9fbb-50657885ed5c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Steve Hannah
Software Developer
Codename One
Reply all
Reply to author
Forward
0 new messages