//比如有一個(gè)json
var json = {"name" : "Tom", "age" : 18};
//想分別獲取它的key 和 value
//小技巧來啦
for (var key in json) {
console.log(key); //獲取key值
console.log(json[key]); //獲取對(duì)應(yīng)的value值
}
//比如有一個(gè)json
var json = {"name" : "Tom", "age" : 18};
//想分別獲取它的key 和 value
//小技巧來啦
for (var key in json) {
console.log(key); //獲取key值
console.log(json[key]); //獲取對(duì)應(yīng)的value值
}