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

Web and WebWorks Development

Reply
New Developer
Posts: 4
Registered: ‎02-09-2010
My Device: Make
My Carrier: DTDC

JSON as a response as supposed to text

Hi,

 

  I am using Widget application to connect to an URL outside the app. context using XMLHttpRequest and i am getting the response as a text as supposed to JSON? Is there any thing we need to change in the config.xml to retrieve it as JSON so that i can use the inbuild DOM to parse it and get the respective data for display?

 

Thanks,

Blackberry Crazy

Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: JSON as a response as supposed to text

Hi There,

 

Your JSON text will only come back as plain text.  You will then need to take the .responseText property of your XMLHttpRequest and parse it into your JSON object.

 

It is recommended that you use a JSON parser to do this and not use eval() function.  Eval can be especially dangerous with the injection of executable code and is typically slower than a JSON parser.

 

The BlackBerry Browser does not have a built in JSON parser, but you can use the open source JSON parser found here:

http://www.json.org/js.html

 

Cheers

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter
New Developer
Posts: 4
Registered: ‎02-09-2010
My Device: Make
My Carrier: DTDC

Re: JSON as a response as supposed to text

Thanks tneil.

 

I have the following doubts to get clarified:-

 

1) Advantages and disadvantages of Java SDK and Widget SDK?

2) When to go for Java SDK and Widget SDK?

3) Both Java and Widget applications require the latest blackberry OS 5.0? OR whether they are compatible with the lower versions as well?

4) Whatever developed with Java SDK can be done with widget SDK? similarly the vice-versa?

5) Is it possible to create the .java classes for Widget application development?

6) Whether all the blackberry models supports both Java and Widget ?

7) What are the Databases the blackberry Java and Widget supports?

 

Thanks,

Blackberry Crazy

 

 

Highlighted
Retired
Posts: 3,708
Registered: ‎10-16-2008
My Device: Z10
My Carrier: Rogers

Re: JSON as a response as supposed to text

[ Edited ]

1) Advantages and disadvantages of Java SDK and Widget SDK?

2) When to go for Java SDK and Widget SDK?

It really depends on your background.  If you are a web developer and don't want to dive into mobile Java development, you can build using the web technologies that you know and love.  Speed of development in the Widget side is quicker as well since your UI is all HTML, CSS where you need to code the UI in Java.  However there are things that are better suited to Java such as streaming data or writing a 3D game.

 

Really what it comes down to is what do you prefer to code in... HTML/JavaScript/CSS or Java

 

3) Both Java and Widget applications require the latest blackberry OS 5.0? OR whether they are compatible with the lower versions as well?

BlackBerry widgets are supported starting with OS 5.0.  Java development can be done back to any of the Java supported devices.

 

4) Whatever developed with Java SDK can be done with widget SDK? similarly the vice-versa?

Yes.. this is technically possible.  The main difference is that the Widget UI is HTML.  In some cases there currently isn't a JavaScript API for some of the Java APIs.  Our goal is to make it that there are no limitations on either technology from a UI and coding standpoint.  If there is a Java API that you want and it is not available yet in JavaScript, you can simply wrap that Java API so that it can be called by your JavaScript.  We have a tutorial available to show how to do this.

 

RIM will be continuing to expand the JavaScript API library to cover all of the same functionality as the Java API.  These JavaScript APIs will not have to wait until a new OS version either.  They will all be usable and compatible with OS 5.0.  If there are new Java APIs introduced in new Operating Systems, then the JavaScript APIs that rely on these Java APIs will also require that new operating system.  But there are currently TONS of APIs available on the 5.0 operating system that the JavaScript APIs can take advantage of and we plan to cover them all as soon as we can.

 

5) Is it possible to create the .java classes for Widget application development?

Yes it is.  We have a lab that shows how you can do this.  The lab demonstrates how this can be done with the Beta tooling.  It will be updated on RTM of the tooling to show how we are making it much easier.  But the code you write today will still be used in the RTM.

http://na.blackberry.com/eng/developers/devbetasoftware/Lab_Widget_Extension.zip

 

6) Whether all the blackberry models supports both Java and Widget ?

All of the new BlackBerry devices coming out support 5.0 or higher.  Also, there are many in market models that will also support OS 5.0

http://www.blackberry.com/btsc/search.do?cmd=displayKC&docType=kc&externalId=KB17984

 

7) What are the Databases the blackberry Java and Widget supports?

Both BlackBerry widgets and Java applications can store data via SQLite starting with OS 5.0.  Prior to 5.0 Java applications could store data in a Persistent object storage mechanism.

 

Hopefully that helps Smiley Happy

Tim Neil
Director, Application Platform & Tools Product Management
Follow me on Twitter