JSON.parse()
Method parses a JSON string to construct a JavaScript value or object that is described by a string. An optional Reviver function can be provided to perform transformations on the resulting object before Returning.
GrammarEDIT
Json.parse (textreviver])
Parameters
-
text
-
To be parsed into a string of Javasctipt values, see a
JSON
description of the JSON syntax for object learning.
-
reviver
options available
-
if it is a function, it specifies how the original value is parsed and transformed before it is Returned.
return value
Object
Corresponds to the given JSON Text.
Abnormal
If the parsed JSON string is illegal, an exception is thrown 语法错误
.
ExampleEDITUse
JSON.parse()
Json.Parse(‘{}‘);{}json.Parse(' True ')//truejson. Parse ( ' "foo" ' ) //"foo" json. Parse (//[1, 5, "false"]json. Parse ( ' null ' //null
The
json.parse () method resolves a JSON string