JSON.stringify(value, [replacer], [space])

Function converts a JavaScript object or an array to a JSON string.

Type: function

Parameter(s):

  • value {Object | Array}:

    Any JavaScript value, usually an object or array

  • replacer {} Optional:

    Optional parameter that determines how object values are stringified for objects. It can be a function or an array of strings.

  • space {} Optional:

    Optional parameter that specifies the indentation of nested structures. If it is omitted, the text will be packed without extra whitespace. If it is a number, it will specify the number of spaces to indent at each level. If it is a string (such as \t), it contains the characters used to indent at each level.

Returns:

  • {String}:

    The resulting JSON string

Example(s):

var str = JSON.stringify(obj);