Ios 当我的jsonstring中字符%EF%BF%BF的内容时,JSONKit objectFromJSONString返回nil
我试图解析从服务器获取的json字符串,但当" , “objectFromJSONString”中的“destDic”将为零。为什么?如何修复JSONKit中的错误 错误_json.txt中的字符串:Ios 当我的jsonstring中字符%EF%BF%BF的内容时,JSONKit objectFromJSONString返回nil,ios,Ios,我试图解析从服务器获取的json字符串,但当" , “objectFromJSONString”中的“destDic”将为零。为什么?如何修复JSONKit中的错误 错误_json.txt中的字符串: + (void)testResponseStr { NSString *responseString = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"error_json" ofType:
+ (void)testResponseStr
{
NSString *responseString = [NSString stringWithContentsOfFile:[[NSBundle mainBundle] pathForResource:@"error_json" ofType:@"txt"] encoding:NSUTF8StringEncoding error:nil];
NSDictionary *destDic = [responseString objectFromJSONString];
NSLog(@"%@",responseString);
if (destDic) {
NSLog(@"success");
}else{
NSLog(@"error");
}
}
您可以使用:
NSString*responseString=[responseString]
StringByReplacingOfString:@““带字符串:@”“]
这不是一个解决方案,但目前可能对您有效尝试使用NSJSONSerialization NSDictionary*destDic=[NSJSONSerialization JSONObject WithData:data options:kNilOptions error:&error];谢谢你,Sachin Nikumbh,它适用于这个字符,但如果我从服务器上获得另一个类似的字符,它将不会被JSONKit再次解析。你知道其他比JSONKit更好的IOS JSON解析工具吗?
{"result":{"hasMore":true,"newestWorksList":[{"hasLiked":false,"hasCollected":false,"tlName":"No smoking","likeCount":1,"title":"No smoking","authorNickname":"","commentCount":0,"uid":"69nbNm","createTime":1453539369000,"id":2546522,"createTimeStr":"2016.01.23","tlIsUserUpload":false}]},"code":0}