原生Json解析
作者:
T92 | 来源:发表于
2016-11-18 19:57 被阅读20次#pragma mark - json解析
-(void) json:(NSString *)jsonUrl{
// 错误信息
NSError *error;
// 加载一个NSURL对象
NSURLRequest *request = [NSURLRequestrequestWithURL:[NSURLURLWithString:jsonUrl]];
//将请求的url数据放到NSData对象中
NSData *response = [NSURLConnectionsendSynchronousRequest:request returningResponse:nilerror:nil];
//IOS5自带解析类NSJSONSerialization从response中解析出数据放到字典中
resultDic = [NSJSONSerializationJSONObjectWithData:response options:NSJSONReadingMutableLeaveserror:&error];
NSLog(@"%@",resultDic);
}
// 调用
[self json:[NSStringstringWithFormat:@"http://baidu.com"]];
本文标题:原生Json解析
本文链接:https://www.haomeiwen.com/subject/ibdspttx.html
网友评论