Ios JSON错误,结果为“\”
我有一个JSON结果,结果中有反斜杠Ios JSON错误,结果为“\”,ios,json,Ios,Json,我有一个JSON结果,结果中有反斜杠 "{\"Info\":[{\"Full_Eng_Nmae\":\"salaiman don\",\"email\":\"hkeer020@gmail.com\ 但无法处理结果 这是我的代码: -(void) processRecessionSafetyTipsWithData:(NSData*)data { NSError *error; NSDictionary* json =[NSJSONSerialization JSONObj
"{\"Info\":[{\"Full_Eng_Nmae\":\"salaiman don\",\"email\":\"hkeer020@gmail.com\
但无法处理结果
这是我的代码:
-(void) processRecessionSafetyTipsWithData:(NSData*)data
{
NSError *error;
NSDictionary* json =[NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingMutableContainers|NSJSONReadingAllowFragments error:&error];
if (!json || error != nil)
{
NSLog(@" The Error is: %@",error.debugDescription);
if(self.delegate)
{
[self.delegate didReceiveProcessingError];
}
}
else
{
recessionTips = [[NSMutableArray alloc] init];
NSArray *tips = [json objectForKey:@"Info"];
for (int i=0; i<tips.count; i++)
{
NSDictionary *tip = (NSDictionary*)[tips objectAtIndex:i];
RecessionTipModel *recessionTip = [[RecessionTipModel alloc] init];
recessionTip.tipdescription = (NSString*)[tip objectForKey:@"email"];
recessionTip.username = (NSString*)[tip objectForKey:@"name"];
[recessionTips addObject:recessionTip];
}
if(self.delegate)
{
[self.delegate didReceiveRecessionTips:recessionTips];
}
}
}
错误是:
无法完成该操作。可可错误3840。JSON文本不是以数组或对象和允许未设置片段的选项开头的
任何人都可以帮我Plz?这不是有效的JSON。创建它的人创建了一个用引号括起来的字符串,并转义了该字符串中的所有引号 因此,如果您能够说服您的数据源提供有效的JSON。如果无法将all\转换为simple,请删除前导引号和尾随引号
然后向JSON序列化程序提供有效的JSON字符串该语言称为Objective-C。XCode只是开发环境。