我有以下 JSON 代码:
{
"chat": [
{
"username": "demo",
"text": "hi man",
"time": "1380167419"
},
{
"username": "admin",
"text": "hi",
"time": "1380167435"
},
{
"username": "demo",
"text": "this works flawless now.",
"time": "1380167436"
},
{
"username": "demo",
"text": "we basically done/",
"time": "1380167443"
}
]
}
当我运行时:
var codes = JSON.parse(history); //history is the above JSON.
$.each(codes, function(key, value){
alert(value.chat.username);
});
它没有提醒任何东西,并一直告诉我 value.chat.username 未定义...
我哪里做错了?