これは、Jsonlint で検証されている私のローカル Json です。
{
"messages": {
"count": "0",
"items": [
{
"MessageID": "1",
"Starred": 0,
"BodyPrev": "You wouldn't believe what has just happenedYou wouldn't believe what has ",
"FromUserID": "1",
"FromName": "Daisy Purdye",
"FromUN": "daisypurdye",
"Subject": "Yeayeah",
"Body": "You wouldn't believe what has just happenedYou wouldn't believe what has just happenedYou wouldn't believe what has just happenedYou wouldn't believe what has just happenedYou wouldn't believe what has just happenedYou wouldn't believe what has just happened",
"Ctime": "10/4/2012",
"isRead": "1"
},
{
"MessageID": "2",
"Starred": 1,
"BodyPrev": "Whatever",
"FromUserID": "1",
"FromName": "Daisy Purdye",
"FromUN": "daisypurdye",
"Subject": "Not true mate",
"Body": "Whatever",
"Ctime": "5/3/2012",
"isRead": "1"
}
]
}
}
ここにメッセージを出力するためのjQueryがあります...
<script>
$.getJSON("/json/messages.json",function(result){
$.each(result, function(i, messages){
console.log(messages.items.Subject)
});
});
</script>
未定義を返すだけです。