Working with JSON
JSON is a text format for sharing data. JavaScript gives you two helpers to move between objects and JSON strings.
JSON.stringifyturns an object into a JSON stringJSON.parseturns a JSON string back into an object
const obj = { name: "Ada", skills: ["js", "html"] };
const text = JSON.stringify(obj);
const back = JSON.parse(text);
Pass a third argument to JSON.stringify, such as 2, to pretty-print with indentation.
Try it yourself
Loading editor…