Name
JSON — JSON parsing and stringification
Availability
ECMAScript 5
Description
JSON is a simple object
that serves as the namespace for the global ECMAScript 5 functions
JSON.parse() and JSON.stringify(). JSON is not a constructor. Prior to
ECMAScript 5, compatible JSON parsing and serialization functions
are available from http://json.org/json2.js.
“JSON” stands for JavaScript Object Notation. JSON is a data
serialization format based on JavaScript literals, and can represent
the null value, the boolean
values true and false, floating-point numbers (using
JavaScript numeric literals), strings (using JavaScript string
literals), arrays of values (using JavaScript array literal syntax)
and string to value mappings (using JavaScript object literal
syntax). The primitive value undefined as well as the numbers NaN and
Infinity are not representable in JSON. JavaScript functions, Dates,
RegExps and Errors are not supported either.
Example
// Make a deep copy of any object or array that can be JSON-serializedfunctiondeepcopy(o){returnJSON.parse(JSON.stringify(o));}
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access