JSON.stringify(obj)

Method Description

Converts a JavaScript object or value to a JSON string

For more information about JSON object format, see http://www.ietf.org/rfc/rfc4627.txt.

Returns

JSON string

Supported Script Types

Client and server scripts

Governance

None

Global object

JSON object

Since

2015.2

Parameters

Parameter

Type

Required / Optional

Description

Since

value

Object

required

The value to convert to a JSON string

2015.2

replacer

Function

optional

Function that changes the behavior of the stringification process

2015.2

space

Object

optional

A string or number that is used to insert white space in the output JSON string for readability

2015.2

Syntax

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

          var contact = {
       firstName: 'John',
       lastName : 'Doe',
       jobTitle : 'CEO'
    };

var jsonString = JSON.stringify(contact); 

        

This method converts the contact object to the following string:

{"firstName":"John","lastName":"Doe","jobTitle":"CEO"}

Related Topics

General Notices