Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
Developer
JKDESAI
Posts: 112
Registered: ‎05-29-2009
My Device: Not Specified
Accepted Solution

Parse JSON response in blackberry

[ Edited ]

Hi, I want to parse the response coming from the server in JSON format.

 

I have done some googling but i can't find any library or jar kind of thing. Everywhere there is provided open source code as zip file.

 

How can i achive this?..& if there is no any jar available for blackberry then how to use that open source code in my application??

 

I have used 1 jar file org.json, but it gives me  the exception "module not found". 

 

please help..... 

 

Thanks in advance.

Message Edited by JKDESAI on 09-24-2009 02:42 AM
Please use plain text.
Developer
jhw1701
Posts: 176
Registered: ‎11-06-2008
My Device: Not Specified

Re: Parse JSON response in blackberry

you didn't google hard enough :smileywink:

 

check json.org for the org.json.me package

Please use plain text.
Developer
tek3
Posts: 190
Registered: ‎07-08-2009
My Device: Not Specified

Re: Parse JSON response in blackberry

download the zip folder of package org.json.me and import it in your project...

 

then use it like..

 

        JSONObject outer=new JSONObject(resp);     // resp is JSON response i am getting
        JSONArray ja = outer.getJSONArray("DATA");
        JSONArray arr=ja.getJSONArray(0);                // for accessing each element of JSON Array.

 

if the response contains JSON Array...A JSON Array will be of the form..

 

"DATA":[ "abc"  , "def"] // DATA isarray name and "abc " and "def" are array elements...

Please use plain text.