var obj = {};
for(var k in obj) {
//遍历对象,k即为key,obj[k]为当前k对应的值
console.log(obj[k]);
}
json是种常用数据传输格式,js怎么解析json格式的数据呢,请参阅下面的代码:
[html] view plain copy print?
{"return_code":0,"return_message":"success","data":{"data":[{"id":"1","question":"公主令牌在哪交?"},{"id":"2","question":"公主护使有什么用?"},{"id":"3","question":"角斗场在哪?"},{"id":"4","question":"北部断层在哪?"},{"id":"5","question":"欢乐令有什么用?"},{"id":"6","question":"令牌积分有什么用?"},{"id":"7","question":"南部断层在哪?"},{"id":"8","question":"大妖魔令牌交给谁?"},{"id":"9","question":"神工坊在哪?"},{"id":"10","question":"警戒妖珠有什么用?"}]}}
参考资料
json官网.json官网[引用时间2018-1-2]