[size=medium]
var jsonData = {"name":"小埋","age":18}; for(var key in jsonData){ console.log(key);//The key of the json object console.log(jsonData[key]);//The value of the json object }[/size]
2. Use the eval() function to convert it to a js object and then parse it:
[size=medium]
var json1 = { "array1" : [ {'item1' : 1}, {'item2' : 2} ] } var obj1 = eval (json1); console.log(obj1.array1[0]['item1']);[/size]
3. Structure assignment in ES6:
[size=medium]
var json2 = { "name" : "umaru", "age" : 18, "array2" : [ {"item" : 1}, {"item" : 2} ] } let {age,name,array2} = json2; console.log(name + age + array2[0]['item']);[/size]
Note: The value of the structure assignment object has nothing to do with the order, and is related to the variable name.