Json.parse: All Error & How to Solve Them

Error Messages:
Uncaught SyntaxError: Unexpected token N in JSON at position 0

JSON.parse(NaN)
JSON.parse('NaN')

Error Messages:
Uncaught SyntaxError: Unexpected token u in JSON at position 0

JSON.parse(undefind)
JSON.parse('undefind')

Error Messages:
Uncaught SyntaxError: Unexpected token o in JSON at position 1

JSON.parse({a:2})

Error Messages:
Uncaught SyntaxError: Unexpected token a in JSON at position 1

JSON.parse('{a:2}')

Error Messages:
Unexpected token ' in JSON at position 1

JSON.parse("{'a':11}")

Error Messages:

JSON.parse('{"a":11}'

**About json.parse

JSON.parseFor parsing JSON string, and returns the corresponding value, which parameters must conform to the format JSON string, otherwise an error.
JSON Is a syntax used to serialize objects, arrays, numbers, strings, Boolean values, and null.
JSON The attribute names of objects and arrays must be strings enclosed in double quotes, and there must be no comma after the last attribute.
JSON The string should also be enclosed in double quotes.
JSON values are forbidden to have leading zeros (JSON.stringify method automatically ignore leading zeros, and the JSON.parse method will report error); if there is a decimal point, then followed by at least one digit.

Read More: