ios - AFNetworking 请求 API iOS
<p><p>我正在向服务器发出请求,服务器返回一个 JSON。 AFNetworking 框架返回格式错误的 JSON。</p>
<p>这是服务器发送的内容:</p>
<pre><code>{"email":"XXXXXXX","firstName":"XXXXXX","lastName":"XXXXXXX","gender":"male","userToken":"XXXXXXXXXXX"}
</code></pre>
<p>这是 AFNetworking 收到的:</p>
<pre><code>{
email = "XXXXXXX";
firstName = XXXXXX;
gender = male;
lastName = XXXXXXX;
token = XXXXXXXXXXXX;
}
</code></pre>
<p>我的代码:</p>
<pre><code>AFHTTPClient *client = [ initWithBaseURL:];
NSURLRequest *request = ;
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);
}];
;
</code></pre></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>您要打印的对象是从服务器接收到的 JSON 的 NSDictionary 表示。 </p>
<p>如果你想查看从服务器返回的原始 JSON,你应该查看操作的 responseString:</p>
<pre><code>NSLog(@"%@", operation.responseString);
</code></pre></p>
<p style="font-size: 20px;">关于ios - AFNetworking 请求 API iOS,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/14024493/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/14024493/
</a>
</p>
页:
[1]