JS COLLECTIONSChapter 4 · JS Collections Depth
JSON
JSON is how data travels between programs and across the web. JSON.stringify(value) turns an object or array into JSON text, and JSON.parse(text) turns JSON text back into a value. Pass extra arguments like JSON.stringify(data, null, 2) for readable, indented output. Functions and undefined values are left out of the text.
Worked example
How it reads
stringifyproduces text with double-quoted keysparsegives you a normal object you can read with dotsundefinedproperties disappear from the JSON

Cloud tip:
JSON.parse throws on invalid text. Wrap it in try...catch when the text comes from outside your program.

