{
data = (
{
"created_time" = "2011-09-28T07:29:37+0000";
from = {
id = 100002944043966;
name = "alok sinha";
};
height = 500;
icon = "https://s-static.ak.facebook.com/rsrc.php/v2/yz/r/StEh3RhPvjk.gif";
id = 114750595299741;
images = (
{
height = 2048;
source = "https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-ash4/s2048x2048/300035_114750595299741_1543248164_n.jpg";
width = 2048;
},
{
height = 500;
source = "https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-ash4/300035_114750595299741_1543248164_n.jpg";
width = 500;
},
{
height = 500;
source = "https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-ash4/300035_114750595299741_1543248164_n.jpg";
width = 500;
},
{
height = 480;
source = "https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-ash4/s480x480/300035_114750595299741_1543248164_n.jpg";
width = 480;
},
{
height = 320;
source = "https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-ash4/s320x320/300035_114750595299741_1543248164_n.jpg";
width = 320;
},
{
height = 180;
source = "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/300035_114750595299741_1543248164_a.jpg";
width = 180;
},
{
height = 130;
source = "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/300035_114750595299741_1543248164_s.jpg";
width = 130;
},
{
height = 130;
source = "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/s75x225/300035_114750595299741_1543248164_s.jpg";
width = 130;
}
);
link = "https://www.facebook.com/photo.php?fbid=114750595299741&set=a.114750591966408.20279.100002944043966&type=1";
picture = "https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/300035_114750595299741_1543248164_s.jpg";
position = 1;
source = "https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-ash4/300035_114750595299741_1543248164_n.jpg";
"updated_time" = "2011-09-28T07:29:38+0000";
width = 500;
}
);
paging = {
next = "https://graph.facebook.com/114750591966408/photos?value=1&redirect=1&limit=25&after=MTE0NzUwNTk1Mjk5NzQx";
};
}
0
votes
4 Answers
2
votes
NSArray *jsonArray; // your parsed array
NSDictionary *dict = [jsonArray objectAtIndex:0]; // there might be more of the objects and you might need to put that into a forin cycle, but for simplicity this is an example for an array with only one dictionary in it
NSArray *images = [dict objectForKey:@"images"];
NSMutableArray *links = [NSMutableArray array];
for (NSDictionary *img in images) {
[links addObject:[img valueForKey:@"source"]];
}
Now links are the array of NSString objects that you need. You can also transform them into NSURLs if you need to.
2
votes
1
votes
[yourDictionary objectForKey:@"data"] gives dictionary.
NSDictionary *dictionary = [yourDictionary objectForKey:@"data"]
NSArray *images = [dictionary objectForKey:@"images"];
NSMutableArray *sourceUrls = [[NSMutableArray alloc] initWithCapacity:0];
for (NSDictionary *subDictionary in images]) {
[sourceUrls addObject:[subDictioanary objectForKey:@"source"]];
}
I think it will be helpful to you.
-1
votes
Include SBJSON parser in your code. Then import SBJson.h in the implementation file. Then Use the below code for it.
NSMutableDictionary *responseDictionary = [yourJsonString JSONValue];
NSArray *imageArray = [responseDictionary objectForKey:@"images"];
NSMutableArray *sourceImage=[[NSMutableArray alloc]init]
for(int i=0;i<[imageArray count];i++){
{
[sourceImage appendString:[[imageArray objectAtIndex:i]objectForKey:@"source"]];
}
(and)are invalid. Equal signs are invalid, semicolons are invalid...is this even JSON? - borrrden