[英]iOS JSON Parsing error
我正在尝试在这里解析json,但由于某种原因继续出错。 我的代码是
NSString *string = [NSString stringWithFormat:@"http://api.wunderground.com/api/3c158b3b3cd6ce90/hourly/q/11758.json"];//, query];
NSString *string2 = [string stringByReplacingOccurrencesOfString:@" " withString:@"_"];
NSData* data = [NSData dataWithContentsOfURL:
[NSURL URLWithString:string]];
NSError* error;
NSDictionary *res = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableLeaves error:&error];
NSArray* latestLoans = [res objectForKey:@"forecast"]; //2
NSArray *tmp = [latestLoans valueForKey:@"temp"];
NSLog(@"temp: %@", tmp);
错误是
temp: (null)
Entity: line 2: parser error : Start tag expected, '<' not found
{
^
我没有收到此邮件,因为该网址是真实的并得到了响应,我需要与此相关的帮助
您所寻找的“预测”在响应中不存在。 也许您正在寻找的是“ hourly_forecast”。
NSArray* latestLoans = [res objectForKey:@"hourly_forecast"]; //2
NSArray *tmp = [latestLoans valueForKey:@"temp"];
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.