JSON Validator Bug
By Adrian Sutton
Is it just me (quite possible) or is the standard JSON validator for JavaScript unable to handle quotes (") in strings? Specifically, shouldn’t the JSON below be considered valid?
{“name”:"""}
It throws a parseJSON error when run through the validator but executes perfectly as JavaScript and seems to match the specification for strings in JSON. It’s frustrating because even though the data is coming straight from the server so it’s as trustworthy as it can get, I still think it’s incredibly poor form to execute data without first validating it.
IMMEDIATE UPDATE: Blogging is wonderful – hitting the publish button immediately enlightens you to what’s going wrong. Turns out JavaScript interprets " even if it’s in single quotes thus the JSON parser was only seeing " without the ’ but executing the JavaScript would still work fine. So it was just me.