ios 字符串(json格式)转化成字典

- (NSDictionary *)dictionaryWithJsonString:(NSString *)jsonString {

if (jsonString == nil) {

return nil;

}

NSData *jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];

NSError *err;

NSDictionary *dic = [NSJSONSerialization JSONObjectWithData:jsonData

options:NSJSONReadingMutableContainers

error:&err];

if(err) {

NSLog(@"json解析失败:%@",err);

return nil;

}

return dic;

}

你可能感兴趣的:(ios 字符串(json格式)转化成字典)