我正在向服务器发出请求,服务器返回一个 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"OST" 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];
Best Answer-推荐答案 strong>
您要打印的对象是从服务器接收到的 JSON 的 NSDictionary 表示。
如果你想查看从服务器返回的原始 JSON,你应该查看操作的 responseString:
NSLog(@"%@", operation.responseString);
关于ios - AFNetworking 请求 API iOS,我们在Stack Overflow上找到一个类似的问题:
https://stackoverflow.com/questions/14024493/
|