YashMittal05 / apex-library

Automatically exported from code.google.com/p/apex-library
0 stars 0 forks source link

Parser fails on escaped characters in strings #3

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
Attempting to parse an escaped double quote in a double quoted string gave an 
error:

08:56:58.427|FATAL_ERROR|superpat.JSONObject.JSONException: Expected a , or }

Class.superpat.JSONObject.<init>: line 201, column 23
Class.superpat.JSONObject.JSONTokener.nextValue: line 1303, column 35
Class.superpat.JSONObject.<init>: line 186, column 25
Class.superpat.JSONObject.<init>: line 219, column 6
Class.superpat.SimpleGeo.getContextFromAddress: line 32, column 16
AnonymousBlock.superpat: line 3, column 22

The problem was in parsing

{"latitude":37.793755,"longitude":-122.395584,"address":"\"1 Market St, San 
Francisco, CA\""}

Looking at the code, it looks like this was on the 'to do list' :-) I fixed 
enough to get my code working, but I couldn't figure out the Apex for

sb.append((char)Integer.parseInt(next(4), 16));

to handle \u and \x :-/

Patch attached.

Original issue reported on code.google.com by metada...@gmail.com on 24 Jan 2011 at 5:04

Attachments: