Link to home
Start Free TrialLog in
Avatar of theartha
thearthaFlag for United States of America

asked on

JSON Exception: Unterminated string at character

Hi There,

I received this exception while pulling all the data into JSON format.

net.sf.json.JSONException: Unterminated string at character 894195 .....

at net.sf.json.util.JSONTokener.syntaxError(JSONTokener.java:512)
      at net.sf.json.util.JSONTokener.nextString(JSONTokener.java:244)
      at net.sf.json.util.JSONTokener.nextValue(JSONTokener.java:352)
      at net.sf.json.JSONArray._fromJSONTokener(JSONArray.java:1158)
      at net.sf.json.JSONArray.fromObject(JSONArray.java:147)
      at net.sf.json.util.JSONTokener.nextValue(JSONTokener.java:358)
      at net.sf.json.JSONArray._fromJSONTokener(JSONArray.java:1158)
      at net.sf.json.JSONArray._fromString(JSONArray.java:1224)
      at net.sf.json.JSONArray.fromObject(JSONArray.java:149)
      at net.sf.json.JSONArray.fromObject(JSONArray.java:127)

any clues?

Please advice.

Thanks.
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

Well - it's pretty clearly telling you what the error is ;) Please post the string
Can you please post the code snippet?
Avatar of theartha

ASKER

@CEHJ: Data is huge and sensitive, is there any way that I can find out the 894195  th character.
What os are you using?
@CEHJ: Windows XP Professional
You could put the string in a file and use an editor that shows the offset
@CEHJ: I used editplus, but couldn't figure it out. Is there any better editor?
notepad++, textpad are other good text editors.
@CEHJ,cmalakar:

I figured out the location:

["A","B","C","O","E","null","null"]

["A","B","C"," ","E","null","null"]

In the first JSON String at character "O", but in the second string at the same location. its empty string.
 because of that empty string I am getting an exception.

Please advice.
ASKER CERTIFIED SOLUTION
Avatar of cmalakar
cmalakar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thanks guys.