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


Thank you for visiting the BlackBerry Support Community Forums.

BlackBerry will be closing the BlackBerry Support Community Forums Device Forums on April 1st (Developers, see below)

BlackBerry remains committed to providing excellent customer support to our customers. We are delighted to direct you to the CrackBerry Forums, a well-established and thorough support channel, for continued BlackBerry support. Please visit http://forums.crackberry.com or http://crackberry.com/ask. You can also continue to visit BlackBerry Support or the BlackBerry Knowledge Base for official support options available for your BlackBerry Smartphone.

"When we launched CrackBerry.com 10 years ago, we set out to make it a fun and useful destination where BlackBerry Smartphone owners could share their excitement and learn to unleash the full potential of their BlackBerry. A decade later, the CrackBerry community is as active and passionate as ever and I know our knowledgeable members and volunteers will be excited to welcome and assist more BlackBerry owners with their questions."

- Kevin Michaluk, Founder, CrackBerry.com

Developers, for more information about the BlackBerry Developer Community please review Join the Conversation on the BlackBerry Developer Community Forums found on Inside BlackBerry.


Reply
Contributor
Posts: 10
Registered: ‎06-05-2012
My Device: 9900
My Carrier: at&t

Re: How to Call Json Service in BlackBerry

yah i am just learning it

can anyone give me complete example how i can parse json into my demo application

 

ben trying from last 2 days

thanx

Developer
Posts: 19,636
Registered: ‎07-14-2008
My Device: Not Specified

Re: How to Call Json Service in BlackBerry

I'm not 100% clear on what you don't undrstand.  You seemm to be able to get the Json.  having got the json, you can parse it.  Are you confused about how to convert this parsed json to Fields on your screen?  That is entirely up to you and not something we can really help with. 

 

If you are struggling with this becuase you don't know how to put Fields on a screen , then just wonder round any of the sample apps to see.  Or perhaps this is helpful:

http://docs.blackberry.com/en/developers/deliverables/18125/

 

I actualy wanted to chip to say I'm not sure about this:

 

String s = new String(data);

 

I think you might want to use UTF-8, since most json I know is sent in UTF-8.  i.e. change the above to something like:

 

String s;

try {

s = new String(data,"UTF-8");

} catch (Exception e) {

// won't happen, UTF-8 is supported

}

Contributor
Posts: 10
Registered: ‎06-05-2012
My Device: 9900
My Carrier: at&t

Re: How to Call Json Service in BlackBerry

[ Edited ]

the thing is that i am not able to hit my service which returns me json values
the service is hosted properly no issues are there i m already using that service in windows phone

 

so what i am doing i am using a httpconnection to communicate with my service

http://www.blackberry.com/developers/docs/4.0.2api/javax/microedition/io/HttpConnection.html

 

and it is always giving me exception at this lin's which are in bold

        String  url="http://myservice.json";
        HttpConnection conn = null;
        try {
            conn = (HttpConnection)Connector.open(url);
            InputStream is = conn.openInputStream();
            byte[] data = net.rim.device.api.io.IOUtilities.streamToBytes(is);
            String s = new String(data);
            JSONObject jo =  new JSONObject(s);;
            is.close();            
        } catch (Exception e) {
            e.printStackTrace();


 

i just read that i need to change some settings for httpconnection in my blackberry descriptor file
do i need to change that kind of settings

http://stackoverflow.com/questions/9112246/httpconnection-connector-openurl-with-touch-phone

please let me know where i can change these settings in my descriptor file if needed so
http://i50.tinypic.com/2i7tmgw.jpg

Developer
Posts: 17,025
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport
My Carrier: O2 Germany

Re: How to Call Json Service in BlackBerry

i suggest to use http://www.blackberry.com/developers/docs/7.1.0api/net/rim/device/api/io/transport/ConnectionFactory...

networking on BB is a bit complicated, but the factory makes it easy again.
----------------------------------------------------------
feel free to press the like button on the right side to thank the user that helped you.
please mark posts as solved if you found a solution.
@SimonHain on twitter
Highlighted
New Developer
Posts: 47
Registered: ‎05-11-2012
My Device: Blackberry Bold 9930
My Carrier: Tmobile

Re: How to Call Json Service in BlackBerry

Hi,

I had a problem when I wanted to parse my json service in thebegining. I used this example to understand 

what's going on.

 

http://stackoverflow.com/questions/9544158/json-parsing-in-blackberry-5-0

 

Hope that is what you are looking for.