{
"docs":{
"count":2,
"users":[
{
"_id":"5acc820965c9633fbd851ff7",
"title":"Yamaha Fazer",
"description":"this is the dummy description for the yamaha bike. ",
"image_url":"http://666a658c624a3c03a6b2-25cda059d975d2f318c03e90bcf17c40.r92.cf1.rackcdn.com/unsplash_52c470899a2e1_1.JPG"
},
{
"_id":"5acc8283aa63b6401ac290f0",
"title":"Apache RR 310",
"description":"this is the dummy description for the Apache RR 310 bike. ",
"image_url":"http://666a658c624a3c03a6b2-25cda059d975d2f318c03e90bcf17c40.r92.cf1.rackcdn.com/unsplash_52c470899a2e1_1.JPG"
}
]
}
}
答案 0 :(得分:1)
应该是这样的
d = myObj.docs.count;
u = myObj.docs.users;
答案 1 :(得分:0)
try this,Its Working Fine.
var demo = data.docs;
alert(demo.count); ///Count
var User = demo.users; ///users
for (j = 0; User.length > j; j++) {
alert(User[j]._id);
alert(User[j].title);
alert(User[j].description);
alert(User[j].image_url);
}
答案 2 :(得分:0)
json:
var data = {
"docs": {
"count": 2,
"users": [
{
"_id": "5acc820965c9633fbd851ff7",
"title": "Yamaha Fazer",
"description": "this is the dummy description for the yamaha bike. ",
"image_url": "http://666a658c624a3c03a6b2-25cda059d975d2f318c03e90bcf17c40.r92.cf1.rackcdn.com/unsplash_52c470899a2e1_1.JPG"
},
{
"_id": "5acc8283aa63b6401ac290f0",
"title": "Apache RR 310",
"description": "this is the dummy description for the Apache RR 310 bike. ",
"image_url": "http://666a658c624a3c03a6b2-25cda059d975d2f318c03e90bcf17c40.r92.cf1.rackcdn.com/unsplash_52c470899a2e1_1.JPG"
}
]
}
}
javascript:
var demo = data.docs;
alert(demo.count); ///Count
var User = demo.users; ///users
for (j = 0; User.length > j; j++) {
alert(User[j]._id);
alert(User[j].title);
alert(User[j].description);
alert(User[j].image_url);
}