Sunday, 15 June 2014

java - Why is JSON invalid when commas in string? -



java - Why is JSON invalid when commas in string? -

anyone know why json invalid?

{"street_address":"stone house lane, peckforton
, tarporley
, london, cheshire"}

i'm using jackson java , it's complaining about

java.lang.illegalargumentexception: com.fasterxml.jackson.core.jsonparseexception: unexpected end-of-input: expecting closing quote string value @ [source: java.io.stringreader@6ad16fc1; line: 1, column: 405]

i noticed json considered invalid on online site well: http://jsonviewer.stack.hu/

answer: thanks, curious i've removed these unreadable characters using tr -cd '\11\12\15\40-\176' < file > cleanfile

after copying/pasting exact text, shows invalid json variable. then, copied/pasted same content notepad (using windows 7) , noted there unusual characters in string (these characters cannot seen in page nor in web editors, i'm using blank space instead):

{"street_address":"stone house lane, peckforton
 , tarporley
 , london, cheshire"} ^ ^ here , here

i removed them , worked expected. copy/paste here:

{"street_address":"stone house lane, peckforton, tarporley, london, cheshire"}

after more in-depth evaluation, hexadecimal representation of char \u80a8.

java json jackson

No comments:

Post a Comment