JSON.parse() Function in JavaScript

Q

Where to get the detailed description of the JSON.parse() Function in JavaScript?

✍: FYIcenter.com

A

Here is the detailed description of the JSON.parse() Function in JavaScript.

Description - The JSON.parse() function parses a JSON string, constructing the JavaScript value or object described by the string. An optional reviver function can be provided to perform a transformation on the resulting object before it is returned.

Syntax -

JSON.parse(text[, reviver])

Parameters -

  • text - Required. The string to parse as JSON text string.
  • reviver - Optional. If a function, this prescribes how the value originally produced by parsing is transformed, before being returned.

Return value - The JavaScript value corresponding to the given JSON text.

Exceptions - Throws a SyntaxError exception if the string to parse is not valid JSON.

Examples -

JSON.parse('{}');              // {}
JSON.parse('true');            // true
JSON.parse('"foo"');           // "foo"
JSON.parse('[1, 5, "false"]'); // [1, 5, "false"]
JSON.parse('null');            // null

For more information on the JSON.parse() function, see JSON.parse() reference page.

 

Using JSON in JavaScript

⇒⇒JSON Tutorials

2017-08-17, 107👍, 0💬