Reputation: 5348
Anyone know why this JSON is invalid?
{"street_address":"Stone House Lane, Peckforton
, Tarporley
, London, Cheshire"}
I'm using Jackson for Java and it's complaining about
java.lang.IllegalArgumentException: com.fasterxml.jackson.core.JsonParseException: Unexpected end-of-input: was expecting closing quote for a string value
at [Source: java.io.StringReader@6ad16fc1; line: 1, column: 405]
I noticed this JSON is considered invalid on this online site as well: http://jsonviewer.stack.hu/
Answer: Thanks, for those who are curious I've removed these unreadable characters using tr -cd '\11\12\15\40-\176' < file > cleanFile
Upvotes: 7
Views: 10402
Reputation: 85779
After copying/pasting your exact text, it shows as an invalid JSON variable. Then, I just copied/pasted the same content into a notepad (using Windows 7) and noted there are strange characters in your string (these characters cannot be seen in this page nor in web editors, so I'm using a blank space instead):
{"street_address":"Stone House Lane, Peckforton
, Tarporley
, London, Cheshire"}
^ ^
here and here
I just removed them and worked as expected. Copy/paste it from here:
{"street_address":"Stone House Lane, Peckforton, Tarporley, London, Cheshire"}
After a more in-depth evaluation, the hexadecimal representation of this char is \u80A8.
Upvotes: 10