JSON.parse(text)

Method Description

Parse a string as a JSON object and returns the object.

The text parameter must conform to the JSON standard. See http://www.ietf.org/rfc/rfc4627.txt.

Returns

Object

Supported Script Types

Client and server scripts

Governance

None

Global object

JSON object

Since

2015.2

Parameters

Parameter

Type

Required / Optional

Description

Since

text

string

required

Text to parse as a JSON object. The string must conform to the JSON standard.

2015.2

reviver

Function

optional

Specifies how to transform the parsed value before it is returned

2015.2

Syntax

The following code snippet shows the syntax for this member. It is not a functional example.

          ...
var text = '{ "employees" : [' +
           '{ "firstName":"John" , "lastName":"Doe" },' +
           '{ "firstName":"Anna" , "lastName":"Smith" },' +
           '{ "firstName":"Peter" , "lastName":"Jones" } ]}';
var obj = JSON.parse(text);
var firstEmp = obj.employees[1].firstName + " " + obj.employees[1].lastName;
... 

        

Related Topics

JSON object
JSON.stringify(obj)

General Notices