umbrae / jsonlintdotcom

Source code for jsonlint.com
http://www.jsonlint.com/
ISC License
403 stars 279 forks source link

Newlines should throw a warning #4

Closed fedemp closed 13 years ago

fedemp commented 13 years ago

Currently the app would take this input as valid: { "foo":{ "bar":"whatever", "zet":"and ever" } } but if you convert it to a string (just like jquery.getJSON does when it gets the JSON file through ajax), browsers (Opera 11 and Firefox 6) wil throw an error because the string contains invalid newline characterers aka the character \n

umbrae commented 13 years ago

Fedemp, if I'm understanding you correctly, that's a limitation of javascript, not of JSON - javascript doesn't support unescaped newlines in strings. Other languages (like python, etc) will parse that just fine - and the JSON spec at http://json.org allows it as well.