当我尝试反序列化在Web服务中打印出的JSON代码时,我继续收到此错误。
这是在php中打印出来的内容:
[{"reply":"yes","admin1":"1066","admin2":"1635"}]
这是我在反序列化json的目标c中的代码:
NSMutableString *loginString = [NSMutableString stringWithString:kLoginURL];
[loginString appendString:[NSString stringWithFormat:@"?username=%@",username.text]];
[loginString appendString:[NSString stringWithFormat:@"&password=%@",password.text]];
[loginString setString:[loginString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
NSLog(@"%@",loginString);
NSURL *url = [NSURL URLWithString:loginString];
//NSError *error1;
NSData *data = [NSData dataWithContentsOfURL:url ];
//NSLog(@"%@",data);
// NSLog(@"error %@",error1);
NSError *error;
json = [NSJSONSerialization JSONObjectWithData:data options:kNilOptions error:&error];
NSLog(@"json error: %@",error);
NSLog(@"%@",json);
NSDictionary *info = [json objectAtIndex:0];
NSLog(@"%@",info);
NSString *reply = [info objectForKey:@"reply"];
NSLog(@"%@",reply);
如果此代码或JSON格式
有任何问题,请与我们联系