0
"weatherIconUrl": [
{
"value": "http://cdn.worldweatheronline.net/images/wsymbols01_png_64/wsymbol_0001_sunny.png"
}
],

this is my json data i can able to fetch data in text type but i can't able to fetch image url from weatherIconUrl array

3
  • 2
    Your question is a bit confusing. Are you asking how to get the url out of the JSON or how to get the image from the url? Commented Apr 11, 2014 at 5:55
  • U want to show the image from JSon url Commented Apr 11, 2014 at 5:56
  • yes i want to show image Commented Apr 11, 2014 at 6:30

2 Answers 2

2

Use following code of line for get value of key @"value"

NSString * imgURLString = [[[myMaindictonary objectForKey:@"weatherIconUrl"] objectAtIndex:0] objectForKey:@"value"];

And convert this string to URL

NSURL *myURL = [NSURL URLWithString:[imgURLString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];

And you can also get image from this URL by

UIImage *myImg = [UIImage imageWithData:[NSData dataWithContentsOfURL:myURL]];
Sign up to request clarification or add additional context in comments.

Comments

0

Its quite easy,

 NSError *jsonParsingError = nil;

 NSArray *weatherArray = [NSJSONSerialization JSONObjectWithData:yourResponseData options:0 error:&jsonParsingError];

 NSLog(@"weatherArray : %@", weatherArray);

 NSString *weatherIconImageURL = [[weatherArray objectAtIndex:0] objectForKey:@"weatherIconUrl"]];

 NSLog(@"weatherIconImageURL : %@", weatherIconImageURL);

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.