JSON.stringify
Summary
Export a JavaScript object to a JSON string.
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