JSON.parse(text, [reviver])

Function parses (decodes) and validates a string as JSON object.

Type: function

Parameter(s):

  • text {String}:

    String to be parsed as JSON object.

  • reviver {Function} Optional:

    The optional reviver parameter is a function that can filter and transform the results. It receives each of the keys and values, and its return value is used instead of the original value. If it returns what it received, then the structure is not modified. If it returns undefined then the member is deleted.

Returns:

  • {Object}:

    The resulting JSON object.

Example(s):

var obj = JSON.parse(str);