Why can't you parse a json with a \n
character in javascript
JSON.parse('{"x": "\n"}')
However when you do JSON.parse(JSON.stringify({"x" : "\n"}))
, it is valid.
http://www.jslint.com/ says that {"x": "\n"}
is a valid JSON. I wonder what does spec says about this?
Update: For those who marked this duplicate, this is not the same question as "How to handle newlines in JSON". This question is more about why can't an unescaped newline character allowed in JSON.