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
rishikeshsinghpbh
Posts: 121
Registered: ‎05-31-2012
My Device: 9900

JSON Library parsing Error

Hi All,

 

 I am using the classes in zip (http://supportforums.blackberry.com/t5/Java-Development/JSON-library/m-p/2468119#M220527 )for JSON parsing

 

But when I am trying to parse the following String Using new JSONObject(string);

 

{"title":"As rupee sinks, RBI to meet oil cos to discuss forex needs","fro":"Financial Times","telcast":"Renouncements","summary":"The Reserve Bank of India will meet with oil company officials in Mumbai later on Monday to discuss their foreign exchange needs, two sources with direct knowledge of the matter told Reuters.\r\n\r\nThe meeting with oil companies, which are the biggest buyers of dollars in domestic currency markets, comes as the rupee slid to a record low of 61.21 against he dollar on Monday.\r\n\r\n\\\\\\\"Various options will be discussed. Oil window has been one of the suggestions,\\\\\\\" said one of the sources on Monday.\r\n\r\nDealers have said the RBI may impose a separate window to oil companies to provide them with US dollars, reducing demand for the greenback in the spot market and thus helping ease downward pressure on the rupee. ","detail":"08-07-2013","type":"text","id":352,"name":"name"}

 

i am getting Exception with message--

com.myapp.parser.JSONException: Unterminated string at character 323

 

Whereas when i check the json with online json format validator, its declare the string as valid json.

 

Please suggest.

 

Thanks.

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

Re: JSON Library parsing Error

copy the string to a text editor and check at index 323 as it tells you.
it looks like the '\r' is complained about. terminate these characters (with another '\').
----------------------------------------------------------
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
Developer
rishikeshsinghpbh
Posts: 121
Registered: ‎05-31-2012
My Device: 9900

Re: JSON Library parsing Error

Hi Simon, 

You were right, i add a extra \ before \r\n\t and it works,

But i have handled  only these characters, should i replace all \ with \\ or specific \r with \\r.

 

Please suggest.

Thanks.

Rishikesh Singh