解析JSON对象
var people = {
"name": "zhangsan",
"age": 18,
"address": "beijing"
};
var json = eval('(' + people + ')');
console.log(json.name);
console.log(json.age);
console.log(json.address);
解析JSON数组
var arr = [{
"name": "zhangsan",
"age": 18,
"address": "beijing"
}, {
"name": "lisi",
"age": 19,
"address": "shanghai"
}, {
"name": "wangwu",
"age": 17,
"address": "hangzhou"
}];
for (var i in arr) {
console.log(arr[i]);
console.log(arr[i].name);
console.log(arr[i].age);
console.log(arr[i].address);
}
var ev = eval('(' + data + ')');
for(var i in ev){
cosole.log(ev[i]);
}