-
Notifications
You must be signed in to change notification settings - Fork 260
Description
It was our goal to have $.parseJSON behave identically to the JSON.parse() method. The docs are ambiguous about this.
Takes a well-formed JSON string and returns the resulting JavaScript object.
This is correct.
Where the browser provides a native implementation of JSON.parse, jQuery uses it to parse the string.
This is correct.
Additionally if you pass in nothing, an empty string, null, or undefined, 'null' will be returned from parseJSON.
An empty string or undefined are not valid well-formed JSON strings and shouldn't return a null, but instead JSON.parse() throws an error. The documented behavior is the actual behavior of $.parseJSON() prior to 1.9.0 but we didn't intend to document a divergence from spec here or turn invalid JSON into a valid case.