0

我正在使用 JSON 解析,我将数据放入名为JSON Array的数组中。在控制台中看起来像

JSON Array=(
 {
    "created_by" = 42;
    "created_on" = "2012-02-29 11:23:37";
    "file_description" = "";
    "file_is_downloadable" = 0;
    "file_is_forSale" = 0;
    "file_is_product_image" = 1;
    "file_meta" = "";
    "file_mimetype" = "image/jpeg";
    "file_params" = "";
    "file_title" = "hand shovel";
    "file_type" = product;
    "file_url" = "images/stories/virtuemart/product/cca3cd5db813ee6badf6a3598832f2fc.jpg";
    "file_url_thumb" = "images/stories/virtuemart/product/resized/cca3cd5db813ee6badf6a3598832f2fc_90x90.jpg";
    "locked_by" = 0;
    "locked_on" = "0000-00-00 00:00:00";
    "modified_by" = 42;
    "modified_on" = "2012-02-29 11:23:37";
    ordering = 0;
    "product_name" = "Hand Shovel";
    published = 0;
    shared = 0;
    "virtuemart_category_id" = 1;
    "virtuemart_media_id" = 13;
    "virtuemart_product_id" = 1;
    "virtuemart_vendor_id" = 1;
},

    {
    "created_by" = 42;
    "created_on" = "2012-02-29 11:35:09";
    "file_description" = "";
    "file_is_downloadable" = 0;
    "file_is_forSale" = 0;
    "file_is_product_image" = 1;
    "file_meta" = "";
    "file_mimetype" = "image/jpeg";
    "file_params" = "";
    "file_title" = "our ladder";
    "file_type" = product;
    "file_url" = "images/stories/virtuemart/product/8cb8d644ef299639b7eab25829d13dbc.jpg";
    "file_url_thumb" = "images/stories/virtuemart/product/resized/8cb8d644ef299639b7eab25829d13dbc_90x90.jpg";
    "locked_by" = 0;
    "locked_on" = "0000-00-00 00:00:00";
    "modified_by" = 42;
    "modified_on" = "2012-02-29 11:35:09";
    ordering = 0;
    "product_name" = Ladder;
    published = 0;
    shared = 0;
    "virtuemart_category_id" = 3;
    "virtuemart_media_id" = 8;
    "virtuemart_product_id" = 2;
    "virtuemart_vendor_id" = 1;
}, 

现在,我需要选择“ file_url_thumb ”,它实际上是单独数组中的图像。请让我知道我该怎么做?

4

3 回答 3

1
//Your array has two dictionary ..


for(NSMutableDictionary *dict in JSON_Array){
       NSString *urlString =  [dict objectForKey:@"file_url_thumb"];
       if(urlString){
       NSURL *url = [NSURL urlWithString:urlString];
       NSData* imageData = [[NSData alloc] initWithContentsOfURL:url]];
       UIImage* image = [[UIImage alloc] initWithData:imageData];
       //show your image on imageview
      }
}

希望对你有帮助

于 2012-06-15T09:50:50.950 回答
0
NSString *str_URL =[ [json objectAtIndex:anIndex] valueForKey:@"file_url_thumb"];
于 2012-06-15T09:48:24.607 回答
0
NSString *urlString = [[jsonArray objectAtIndex:0] objectForKey:@"file_url_thumb"];

这将为您提供“file_url_thumb”作为字符串的值。

于 2012-06-15T09:53:37.240 回答