?
u
/
The JSON object:
parse
and stringify
,new
operator.The JSON Data Interchange Format is defined in ECMA-404. The JSON interchange format used in this specification is exactly that described by ECMA-404. Conforming implementations of JSON.parse
and JSON.stringify
must support the exact interchange format described in the ECMA-404 specification without any deletions or extensions to the format.
This function performs the following steps when called:
This function parses a JSON text (a JSON-formatted String) and produces an
The optional reviver parameter is a function that takes two parameters, key and value. It can filter and transform the results. It is called with each of the key/value pairs produced by the parse,For each value produced by the parse, it is called with three arguments (the key, the value, and a context object containing [for unmodified primitive values] details of the corresponding
The parse
function is
Valid JSON text is a subset of the ECMAScript
However, because JSON.parse
, the same source text can produce different results when evaluated as a JSON.parse
, means that not all texts accepted by JSON.parse
are valid as a
A JSON Parse Record is a
JSON Parse Records have the fields listed in
Field Name | Value | Meaning |
---|---|---|
[[ParseNode]] | a |
The context |
[[Key]] | a |
The |
[[Value]] | an |
The value produced by evaluation of [[ParseNode]]. |
[[Elements]] | a |
|
[[Entries]] | a |
The abstract operation CreateJSONParseRecord takes arguments parseNode (a
{"a":"lost","a":"kept"}
), the value for the corresponding property of the resulting ECMAScript object is specified by the last pair with that name.The abstract operation InternalizeJSONProperty takes arguments holder (an Object), name (a String), reviver (a
This algorithm intentionally does not throw an exception if either [[Delete]] or
It performs the following steps when called:
It is not permitted for a conforming implementation of JSON.parse
to extend the JSON grammars. If an implementation wishes to support a modified or extended JSON interchange format it must do so by defining a different parse function.
In the case where there are duplicate name Strings within an object, lexically preceding values for the same key shall be overwritten.
The
JSON.parse
built-in number
token may represent a negative value. In ECMAScript, negation is represented as a unary operation.The rawJSON
function returns an object representing raw JSON text of a string, number, boolean, or null value.
value
is an object
or array
as defined in that specification.The stringify
function returns a String in UTF-16 encoded JSON format representing an
The abstract operation SerializeJSONProperty takes arguments state (a
The
The
© 2023 Richard Gibson
All Software contained in this document ("Software") is protected by copyright and is being made available under the "BSD License", included below. This Software may be subject to third party rights (rights from parties other than Ecma International), including patent rights, and no licenses under such third party rights are granted under this license even if the third party concerned is a member of Ecma International. SEE THE ECMA CODE OF CONDUCT IN PATENT MATTERS AVAILABLE AT https://ecma-international.org/memento/codeofconduct.htm FOR INFORMATION REGARDING THE LICENSING OF PATENT CLAIMS THAT ARE REQUIRED TO IMPLEMENT ECMA INTERNATIONAL STANDARDS.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:
THIS SOFTWARE IS PROVIDED BY THE ECMA INTERNATIONAL "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL ECMA INTERNATIONAL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.