0

I am using JSON parsing, I put data in array named JSON Array. In console it looks like

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;
}, 

Now from this i need to select "file_url_thumb" which is actually image in seperate array. please let me know how can i do this?

8
  • What have you tried? Show the code that you have for parsing your JSON and extracting the data and explain what you have tried and in what way it isn't working. We aren't here to write your code for you. Commented Jun 15, 2012 at 9:41
  • [json objectForKey:@"file_url_thumb"]; Commented Jun 15, 2012 at 9:42
  • Also we can see their are two groups in which separate "virtuemart_category_id" is there depending on that id how can i put that complete group content in some other array Commented Jun 15, 2012 at 9:42
  • @NickBull actually first i need to separate these two group in two array depending on "virtuemart_category_id" for this i am using text field. i.e. if enter 3 in text field , group content "virtuemart_category_id"=3 must get seperated in some other array. and then out of that i need to search "file_url_thumb" which is actually image, to show in image view Commented Jun 15, 2012 at 9:47
  • i tried this for (int i=0; i<[jsonArray count]; i++) { if ([[[jsonArray objectAtIndex:i]valueForKey:@"virtuemart_category_id"]isEqual:compare]) { [ tempArray addObject:[jsonArray objectAtIndex:i]]; } } NSLog(@"Selected Array=%@",containsAnother); Commented Jun 15, 2012 at 9:53

3 Answers 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
      }
}

Hope this will help you

Sign up to request clarification or add additional context in comments.

Comments

0
NSString *str_URL =[ [json objectAtIndex:anIndex] valueForKey:@"file_url_thumb"];

Comments

0
NSString *urlString = [[jsonArray objectAtIndex:0] objectForKey:@"file_url_thumb"];

This will give you value for "file_url_thumb" as a string.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.