我试图在这里解析一个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
{
^
我没有得到这个,因为 URL 是真实的并且得到了响应,我需要这方面的帮助