jquery json获取对象的所有部分

jquery json获取对象的所有部分,jquery,json,Jquery,Json,我用一些对象设置了一个json文件,如下所示: { "everfi_commons":{ "info" : { "projTotal" : "everfi_Commons", "company" : "Everfi", "name" : "Commons", "type" : "ipad", "description" : "this product, bla bla bla bla bl

我用一些对象设置了一个json文件,如下所示:

{
"everfi_commons":{
   "info" : {
               "projTotal" : "everfi_Commons",
       "company" : "Everfi",
       "name" : "Commons",
               "type" : "ipad",
       "description" : "this product, bla bla bla bla bla",
       "folder": "everfi_commons",
               "thumbProjName": "COMMONS",
               "thumbDescription" : "bla bla bla bla bla"
   },
   "images" : {
       "image_1" : "image one url",
       "image_2" : "image two url",
       "image_3" : "image three url",
       "image_4" : "image four url"
   }
},
"project_two":{
   "info" : {
               "projTotal" : "project_two",
       "company" : "Everfi",
       "name" : "Commons",
               "type" : "html5",
       "description" : "this product, bla bla bla bla bla",
       "folder": "project_two",
               "thumbProjName": "COMPANY 2",
               "thumbDescription" : "bla bla bla bla bla"
   },
   "images" : {
       "image_1" : "image one url",
       "image_2" : "image two url",
       "image_3" : "image three url",
       "image_4" : "image four url",
               "image_5" : "image five url"
   }
}
}
我知道如何访问对象的特定部分,但我想知道的是,是否有办法进入everfi_commons.images,然后获取所有的图像URL,不管有多少个URL被列出并放入一个div


谢谢你给我的任何帮助

当然。首先将JSON解析为一个对象,然后在everfi_commons.images上迭代:

var data = $.parseJSON(...);
for(image in data.everfi_commons.images) {
    alert(data.everfi_commons.images[image]); // or whatever you want
}

如果通过AJAX调用检索JSON,那么您甚至不需要
$。parseJSON
,因为如果服务器在响应中发送正确的
内容类型,jQuery将自动执行此操作。

Cooooll,谢谢!