【发布时间】:2011-05-19 04:00:43
【问题描述】:
这是我从 JSON 得到的
[{"照片":null}]
我使用这个代码
NSMutableArray *jPhoto = [NSMutableArray arrayWithArray:(NSArray *)[jsonDict valueForKey:@"photo"]];
如果我想使用 if() 如何检查它?
编辑
这里是 JSON 数据
[{"photo":
[{"image":"http:\/\/www.yohyeh.com\/upload\/shisetsu\/13157\/photo\/1304928459.jpg","title":"test picture","content":"this is description for test picture.\r\n\u8aac\u660e\u6587\u306a\u306e\u306b\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb\u30fb"}
,{"image":"http:\/\/www.yohyeh.com\/upload\/shisetsu\/13157\/photo\/1304928115.jpg","title":"nothing","content":"iMirai"}
,{"image":"http:\/\/www.yohyeh.com\/upload\/shisetsu\/13157\/photo\/1303276769.jpg","title":"iMirai","content":"Staff"}]}
]
这是我的 JSON 解析器
NSError *theError = nil;
NSString *URL = [NSString stringWithFormat:@"http://www.yohyeh.com/apps/get_sub_detail.php?id=%@&menu=photo",g_id];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:URL]];
NSURLResponse *theResponse =[[[NSURLResponse alloc]init] autorelease];
NSData *data = [NSURLConnection sendSynchronousRequest:request returningResponse:&theResponse error:&theError];
NSMutableString *string = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
NSDictionary *jsonDict = [string JSONValue];
感谢帮助
【问题讨论】:
-
您使用的是哪个 JSON 解析器?
-
我使用 JSON 框架。照片中有很多属性,不仅仅是图片链接,还有很多东西。我不确定我是否正确。但我认为 NSMutable 还可以。或不 ???请指导我。 :)
-
如果您发布一个更完整的 JSON 数据示例以及您用于解析它们的代码,将会有所帮助。
-
哦,这个。如果我使用 NSMutableArray。我可以使用这个 if([jPhoto objectAtIndex:0]== [NSNull null]) { } 并且它可以工作。感谢您的帮助。但我仍在等待巴伐利亚的指南。 :)
标签: iphone objective-c ios json nsmutablearray