var msg = "{'id': 1, 'name': '张飞'}"; msg = eval("("+msg+")"); for (var key in msg) { alert("key = " + key + " value = " + msg[key]); }
? ?上面的这种可能没有下面的这种json看的透彻
??
??? 下面再来一种特别的:
window.onload = function() { var json = { "China": " [{'City':'上海','value':'1'},{'City':'南京','value':'2'},{'City':'杭州 ','value':'3'},{'City':'武汉','value':'4'}]" } var datas = eval(json.China); for (var i = 0; i < datas.length; i++){ alert(datas[i].City); alert(datas[i].value); } }
?