This page is Ready to Use

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

JSON.stringify

Summary

Export a JavaScript object to a JSON string.

Method of apis/jsonapis/json

Syntax

var  = JSON.stringify(JavaScript object);

Parameters

JavaScript object

Data-type
String

The JavaScript object to convert to a string.

Return Value

Returns an object of type StringString

A string representation of the JavaScript object.

Examples

// Returns string '{"type":"Mage","stats":[10,3,5]}'
JSON.stringify({
  type: 'Mage',
  stats: [10, 3, 5]
});

Related specifications

JSON-LD 1.0
W3C Recommendation