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
Regular Contributor
divya
Posts: 77
Registered: ‎02-17-2010
My Device: Not Specified

JSON

Hi All,

 

 whats the maximum data can be read ? my app reads 1.2mb data from server ,converts inputstream to strign and gives it to json parsing. my mds server configured to receive 1024kbs (IPPP.connection.MaxNumberOfKBytesToSend=1024 )

 

since my data is 1.2mb i changed the above value to 2048,1500 and checked out.. now response code is 200 but it never enters my json parsing code..i tried in debug mode too as soon as it complets reading from server app stops..

am unable to figure out poblem.. can u please help me ?

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: JSON

working with big data is unreliable even without the MDS limitations.
if you have control over the server you can maybe use several smaller transmissions.
----------------------------------------------------------
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
Regular Contributor
divya
Posts: 77
Registered: ‎02-17-2010
My Device: Not Specified

Re: JSON

i cant alter the server side.. can u please suggest me some other way of parsing huge data ? atleast 2 mb ?
Developer
peter_strange
Posts: 19,610
Registered: ‎07-14-2008
My Device: Not Specified

Re: JSON

I recommend you divide this problem into two parts

 

a) Download the data to the SD Card and save the bytes.  Then you can free up the connection.  You could use this approach so that you don't have to worry about connection limits:

http://supportforums.blackberry.com/t5/Java-Development/Download-large-files-using-the-BlackBerry-Mo...

 

b) Parse the file from the SD Card.

 

You can actually develop and test both of these parts independently.  And you test how long each is going to take.

 

With respect to speeding up the parsing, there is little you can do about this, unless you try an easier to parse format.  In terms of 'standard' formats, I think json is about the most efficient, but if you know the stricture of your data perhaps you can design something specific for your situation.

 

But in your situation, I would try to redesign the approach around a smaller download.  Perhaps you can receive and process a bit at a time?

 

 

Regular Contributor
divya
Posts: 77
Registered: ‎02-17-2010
My Device: Not Specified

Re: JSON

[ Edited ]

Thanks for the reply peter..i will try this method

one thing i figured out in my app is data is successfully getting downloaded from server ..but while parsing that too especially getting json object from string (downloaded input stream is converted to string and given to json parser) app stops working..

 

jObject = new JSONObject(response); // app stops working here

 

is that the string is too large for parser to process ?

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

Re: JSON

"is that the string is too large"

 

Sorry, I have no idea, 

 

In your situation I would probably look at the json source and try to figure out where to put some 'debugging' in and try that.  If you are developing in OS 6.0 and using the standard json parser this won't be possible, so you will need to get your own json source and include that.  There are a number of Threads on this forum that shoud help you with doing this.

 

Or try some smaller string, steadily increasing length?

Developer
simon_hain
Posts: 16,282
Registered: ‎07-29-2008
My Device: Z10 LE, Z30, Passport

Re: JSON

there are also a number of online parsers/validating tools where you can copy the downloaded string and check it.
----------------------------------------------------------
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
Contributor
hrnt
Posts: 23
Registered: ‎02-22-2011
My Device: Not Specified

Re: JSON

My protocol uses JSON messages that are around 2 megabytes at the moment, and at least Curve 8520 (and 9800 simulator) can deal with it, although slowly. The part that takes most time is indeed creating the initial JSONObject.

 

I am not using the JSON library that ships with 6.0.0, though (because it is not available on 5.0.0, and because it contains a rather stupid bug (StringWriter with no #toString)) - I am using the org.json.me library that I think was used when RIM implemented its own JSON library.

Developer
nish1013
Posts: 253
Registered: ‎08-14-2010
My Device: Not Specified

Re: JSON

got the exact situation.

 

If u find any solution please post.

 

Thank u in advance

Developer
nish1013
Posts: 253
Registered: ‎08-14-2010
My Device: Not Specified

Re: JSON

JSONObject jobj =        new JSONObject(response.toString());

 response is a StringBuffer.

 

try and see whether it works for u?