我正在使用 NSJSONSerialization 类来解析以下 JSON 数据,但是,它返回 null。我的 JSONData 前面有标题,“jsonp1343930692(”。有什么办法可以在放入 NSJSONSerialization 之前处理/消除它?
jsonp1343930692("snapshot":[{"timestamp":1349143800,"data":[{"label_id":10,"lat":29.7161,"lng":-95.3906,"attr":{"ozone_level":37,"exp":"IN","gridpoint":"29.72:-95.39"}},{"label_id":10,"lat":30.168456,"lng":-95.50448}]}]})
我也把我的代码放在这里只是给快照:
(void) httpRequest
{
url1=[NSURL URLWithString: url];
_weak ASIHTTPRequest *request1=[ASIHTTPRequest requestWithURL:url1];
[request1 setCompletionBlock:^{
requestData=[request1 responseData];
[self parsing];
}];
}
(void) parsing
{
NSError myError =nil;
NSDictionary *dic=[NSJSONSerialization JSONObjectWithData:requestData options:NSJSONMutableLeaves error:&myError];
NSLog(@"%@",dic);
}