我正在向服务器发出请求,服务器返回一个 JSON。AFNetworking 框架返回格式错误的 JSON。
这是服务器发送的内容:
{"email":"XXXXXXX","firstName":"XXXXXX","lastName":"XXXXXXX","gender":"male","userToken":"XXXXXXXXXXX"}
这是 AFNetworking 收到的:
{
email = "XXXXXXX";
firstName = XXXXXX;
gender = male;
lastName = XXXXXXX;
token = XXXXXXXXXXXX;
}
我的代码:
AFHTTPClient *client = [[AFHTTPClient alloc] initWithBaseURL:[NSURL URLWithString:server_ip]];
NSURLRequest *request = [client requestWithMethod:@"POST" path:path parameters:params];
AFJSONRequestOperation *operation = [AFJSONRequestOperation JSONRequestOperationWithRequest:request success:^(NSURLRequest *request, NSHTTPURLResponse *response, id JSON) {
NSLog(@"%@", JSON);
} failure:^(NSURLRequest *request, NSHTTPURLResponse *response, NSError *error, id JSON) {
NSLog(@"Request Failed with Error: %@, %@", error, error.userInfo);
}];
[operation start];