Open GoogleCodeExporter opened 9 years ago
[deleted comment]
This is issue is present when you have double-quotes within the json object:
For example:
String body = '{"name":"Hi Ron is \\"this\\" working? "}';
JSONObject jObj = new JSONObject( new JSONObject.JSONTokener( body ) );
system.assertNotEquals(jObj, null);
Original comment by aldo...@gmail.com
on 7 Sep 2011 at 7:04
I fixed the issue adding the following method to JSONObject.JSONTokener class
/*
* Sanitize Json input -- Aldo Fernandez @aldoforce
*
* @return sanitized string
*/
public String sanitize(String s) {
String result;
try {
result = s.replace('\\"', '\'');
}
catch (Exception ex) {
result = '';
}
return result;
}
Then modify the JSONObject.JSONTokener constructor to use the method described
above:
Look in the line #996 and modify:
this.reader = s;
with
this.reader = this.sanitize(s);
Regards,
--Aldo
@aldoforce
Original comment by aldo...@gmail.com
on 7 Sep 2011 at 7:57
Original issue reported on code.google.com by
geekyos...@gmail.com
on 18 Apr 2011 at 7:23