//iOS解析json字符串
- (NSMutableArray *)commentFromJsonStr:(NSString *)jsonStr {
NSMutableArray *commentDataArr = [[NSMutableArray alloc]init];
if (jsonStr == nil || [jsonStr isEqualToString:@""] ) {
return nil;
}
NSData *jsonData = [jsonStr dataUsingEncoding:NSUTF8StringEncoding];
NSError *error;
NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData options:NSJSONReadingMutableContainers error:&error];
NSArray *dataArray = [CommentModel mj_objectArrayWithKeyValuesArray:dic];
for (CommentModel *model in dataArray) {
[commentDataArr addObject:model];
}
return commentDataArr;
}
网友评论