I’m not able to fetch the value from “statisticalEvidence” in the below JSON output as “key”,”value” pair.
JSON Output:
{
"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}\""
}
}}
]
}
}
}
}
I’m able to fetch the “id” as below:
$.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;
}
});
Kindly suggest how to fetch the values in statisticalEvidence as a array.
Try below,
Then use
$.parseJSONFull code:
Note:
statisticalEvidencein your data is an Object not an Array.