Hi,
Thank you. Got it to work with
JSONObject jsonResponse = JSONObject.fromObject(strResponse);
and
also there was no need to do the replacement function etc this way was
able to use the same response string as in javascript.
Cheers and thx for the lib
________________________________
From: zapping zapping <zap...@ya...>
To: jso...@li...
Sent: Tuesday, June 2, 2009 9:34:44 PM
Subject: [json-lib-user] Parsing problem
Hi,
I have a json string that is returned from a service like
{success:"true",code:"200",dataType:"object",objClass:"Message",data:{text:"The room is free. You can start a meeting"}}
When i try to parse it
JSONObject jsonResponse = (JSONObject)JSONSerializer.toJSON(strResponse);
I get an Invalid exception. But the same response string i am able to parse with javascript but not in Java. Tried replacing the quotes with
strResponse = strResponse.replaceAll("\"", "\\\\\"");
But still throws invalid exception. But when i try it this way with a constant it parses
String strResponse = "{success:\"false\",code:\"300\",dataType:\"object\",objClass:\"Message\",data:{text:\"Unparseable date: 'June 03 2009 11:15:00 AM EDT'\"}}";
JSONObject jsonResponse = (JSONObject)JSONSerializer.toJSON(strResponse);
But not directly from the service.
Can you help me out.
Thx,
Zaps
|