檢索字符串數組鍵值對,我不能夠在下面的輸出JSON作爲「鑰匙」,「值」對來從「statisticalEvidence」的值。如何從JSON jQuery中
JSON輸出:
{
"query": {
"count": 1,
"lang": "en-US",
"results": {
"entities": {
"total": "10",
"lang": "en-US",
"entity": [
{
"id": "FZZNDK3XM3VIPLW76QHCAYF2D4",
"rank": "10",
"scores": {
"score": {
"attribute": "contentCreator",
"context": "yct:001000012",
"value": "1.0",
"statisticalEvidence": "\"{\"totalNoOfAbusiveComments\":0,\"totalNoOfThumbsDown\":22,\"totalNoOfPositiveRatedComments\":70,\"totalNoOfReplies\":8,\"totalNoOfLikedComments\":20,\"totalNoOfEngagingReplies\":13,\"totalNoOfThumbsUp\":35,\"totalNoOfComments\":79}\""
}
}}
]
}
}
}
}
我能得到一個 「ID」,如下:
$.get(url,function(data) {
var json = jQuery.parseJSON(data);
for(var i in json.query.results.entities.entity){
var id = json.query.results.entities.entity[i].id;
}
});
請建議如何在statisticalEvidence值作爲數組提取。
你想要這樣的東西? '[{key:'count',value:1},{key:'lang',value:'en-US'}]'? – Brad
@Brad ..其實我想獲取「totalNoOfAbusiveComments」:0,「totalNoOfThumbsDown」:22 – Ravinandan
這不是一個數組,這是一個對象。 JavaScript中的數組只能有數字索引。 – Brad