JQuery. parseJSON (json) converts a JSON string to a js object, and the jquery string to json
Overview
Accepts a JSON string and returns the parsed object.
Inputting a malformed JSON string throws an exception. For example, the following are malformed JSON strings:
{Test: 1} (test is not surrounded by double quotation marks)
{'Test': 1} (using single quotes instead of double quotes)
In addition, if you do not input anything, or an empty string, null, or undefined, parseJSON will return null.
Parameters
JsonString
JSON string to be parsed
Example
Description:
Parses a JSON string
JQuery code:
Var str = '{"name": "John"}'; var obj = jQuery. parseJSON (str); alert (obj. name = "John ");
How can I convert a JSON string to a JS object?
Json format requirements are simple. Any amount that appears must be enclosed in double quotation marks '{"name": "zs", "age": "3"}'.
Second, evalJSON () does not know where the above method is. jQuery provides a method to parse string as json. jQuery. parseJSON (str)
How can I convert the json object returned in the background to a js object?
Var obj = You can return the result. js is parsed to json by default. If you get the result, for example, obj. success obj. data [0]. str2.