The conversion between json objects and json strings is also called serialization and deserialization

Definition : JSON (JavaScript Object Notation) A simple data format, a relatively lightweight data storage format
json string : the so-called string: single quotes or double quotes

var person='{"name":"shily","sex":"女","age":"23"}';//json字符串console.log(person)//{"name":"shily","sex":"女","age":"23"}
console.log(person.name)//undefined
console.log(typeof person)//string

json object : the most significant feature: the value of the object can be accessed with "object. attribute"

var person={
    
    "name":"shily","sex":"女","age":"23"}//json对象
console.log(person);//{name:"shily",sex:"女", age:"23"}
console.log(person.name);// shily
console.log(typeof person);//object

1: JSON.stringify(jsonObj) json object to json string
2: JSON.parse(jsonStr) json string to json object
3: eval("(" + str + “)”) JSON string to JSON object
4 : $.parseJSON(jsonStr) If you use jq, use the method that comes with jq

Guess you like

Origin blog.csdn.net/GongWei_/article/details/109672249