0
{
    数据 = (
                {
            "created_time" = "2011-09-28T07:29:37+0000";
            从 = {
                ID = 100002944043966;
                name = "alok sinha";
            };
            高度 = 500;
            图标=“https://s-static.ak.facebook.com/rsrc.php/v2/yz/r/StEh3RhPvjk.gif”;
            ID = 114750595299741;
            图片 = (
                                {
                    高度 = 2048;
                    来源=“https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-ash4/s2048x2048/300035_114750595299741_1543248164_n.jpg”;
                    宽度 = 2048;
                },
                                {
                    高度 = 500;
                    来源=“https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-ash4/300035_114750595299741_1543248164_n.jpg”;
                    宽度 = 500;
                },
                                {
                    高度 = 500;
                    来源=“https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-ash4/300035_114750595299741_1543248164_n.jpg”;
                    宽度 = 500;
                },
                                {
                    高度 = 480;
                    来源=“https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-ash4/s480x480/300035_114750595299741_1543248164_n.jpg”;
                    宽度 = 480;
                },
                                {
                    高度 = 320;
                    来源=“https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-ash4/s320x320/300035_114750595299741_1543248164_n.jpg”;
                    宽度 = 320;
                },
                                {
                    高度 = 180;
                    来源=“https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/300035_114750595299741_1543248164_a.jpg”;
                    宽度 = 180;
                },
                                {
                    高度 = 130;
                    来源=“https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/300035_114750595299741_1543248164_s.jpg”;
                    宽度 = 130;
                },
                                {
                    高度 = 130;
                    来源=“https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/s75x225/300035_114750595299741_1543248164_s.jpg”;
                    宽度 = 130;
                }
            );
            链接=“https://www.facebook.com/photo.php?fbid=114750595299741&set=a.114750591966408.20279.100002944043966&type=1”;
            图片=“https://fbcdn-photos-a.akamaihd.net/hphotos-ak-ash4/300035_114750595299741_1543248164_s.jpg”;
            位置 = 1;
            来源=“https://fbcdn-sphotos-a.akamaihd.net/hphotos-ak-ash4/300035_114750595299741_1543248164_n.jpg”;
            "updated_time" = "2011-09-28T07:29:38+0000";
            宽度 = 500;
        }
    );
    分页 = {
        下一个 = "https://graph.facebook.com/114750591966408/photos?value=1&redirect=1&limit=25&after=MTE0NzUwNTk1Mjk5NzQx";
    };
}

4

4 回答 4

2
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"]];
}

现在链接是您需要的 NSString 对象数组。如果需要,您还可以将它们转换为 NSURL。

于 2012-07-09T09:50:54.720 回答
2

好吧,您的图像数组就是[jsonObject objectForKey:@"images"]如此循环所有这些并拍摄[loopObject objectForKey:@"source"],最后,不要忘记[jsonObject objectForKey:@"source"]

于 2012-07-09T09:51:22.113 回答
1

[yourDictionary objectForKey:@"data"]给字典。

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"]];
                }

我想这会对你有所帮助。

于 2012-07-09T09:52:22.733 回答
-1

在您的代码中包含 SBJSON 解析器。然后在实现文件中导入SBJson.h。然后使用下面的代码。

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"]];
}
于 2012-07-09T09:51:04.730 回答