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
Developer
anphorea
Posts: 134
Registered: ‎11-27-2012
My Device: Z10 LE,Dev Alpha C

Document NEEDED for the JSON_Reader lib when creating webworks ext

Thanks

I can't find any documents anywhere.

 

I want to process some json file

 

for Example:

{"message":" data get error",
"result":"FAIL",
"data":{
 "con1":"cone",
 "con2":"dataaaaa"
}}

 

/*
WebWorks Developer
*/
BlackBerry Development Advisor
oros
Posts: 1,557
Registered: ‎04-12-2010
My Device: BlackBerry Z10

Re: Document NEEDED for the JSON_Reader lib when creating webworks ext

[ Edited ]

If I'm understanding correctly, you have JSON in a file and wish to use it in your application, is that right?

 

You should be able to use an XMLHttpRequest to retrieve the file and you can then call JSON.parse() on the returned string to create the JSON object. This would give you a JSON object you can work with inside your application.

 

There is a good tutorial on XHR here:
http://www.html5rocks.com/en/tutorials/file/xhr2/

 

And a specific JSON example in the cross-domain request section of the tutorial.

 

var xhr = new XMLHttpRequest();
xhr.open('GET', 'http://www.example2.com/hello.json');
xhr.onload = function(e) {
  var data = JSON.parse(this.response);
  ...
}
xhr.send();

Source: http://www.html5rocks.com/en/tutorials/file/xhr2/

 

 

EDIT: Regarding JSON_Reader lib and WebWorks extensions, can you provide more information about this library? Which are you exactly looking to implement, is this a BlackBerry library or a third-party library?


Erik Oros | @WaterlooErik | eoros@blackberry.com | Developer Issue Tracker

If a reply has answered your question, please click Accept as Solution to help other visitors in the future.