gpt4 book ai didi

ios - AFNetworking在JSON响应键中添加引号

转载 作者:行者123 更新时间:2023-12-01 19:03:41 24 4
gpt4 key购买 nike

我有一个奇怪的错误,我无法解决问题。
我正在构建一个使用远程JSON API进行通信的应用程序。
我正在使用AFNetworking进行请求,并遇到与序列化响应有关的问题。

当我使用浏览器向我们的服务器打电话时,我得到了正确的json响应:

{
{
"tip_uuid": "4067d78c-a222-4190-8d5b-a6822a38e5e6",
"deck_uuid": "c3c0854e-1f28-45ea-a643-c253b5c66a45",
"user_uuid": "fb1dff53-b97f-47f3-b4e7-6c2184b85466",
"latitude": "52.66",
"longitude": "4",
"categoryName": "Other",
"imageURL": "\/images\/dummy_300.png",
"averageRating": 3,
"distanceToLocation": "7596772",
"isUserAwesome": true
},
..... (100 more responses)
}

但是当我使用AFNetworking打同样的电话时

[编辑]
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; 
manager.responseSerializer = [AFJSONResponseSerializer serializer];
[manager.requestSerializer setValue:@"application/json" forHTTPHeaderField:@"ACCEPT"];
[manager POST:URLString parameters:parameters success:^(AFHTTPRequestOperation *operation, id responseObject) {
[self processServerResponse:responseObject successBlock:success failureBlock:failure];
}failure:^(AFHTTPRequestOperation *operation, NSError *error) {
DLog(@"------- Failed url: %@ AFNetworking operation: %@. Responsestring: %@", URLString, [error description], operation.responseString);
showM2(NSLocalizedString(@"Network error", @"Network error title"), NSLocalizedString(@"Please try again later", @"network error message"));
failure(nil);
}];

我得到答复:
[/编辑]
{
{
averageRating = 0;
categoryName = Music;
"deck_uuid" = "c3c0854e-1f28-45ea-a643-c253b5c66a45";
distanceToLocation = 5718;
imageURL = "/images/tip/fb1dff53-b97f-47f3-b4e7-6c2184b85466_4dd49562817bc39f7567321c22469e7bf846f902_1389202937.png";
isUserAwesome = 0;
latitude = "52.3664193";
longitude = "4.8871613";
"tip_uuid" = "83d5a3f7-be60-4974-9347-67cadc307790";
"user_uuid" = "fb1dff53-b97f-47f3-b4e7-6c2184b85466";
},
....(100 more responses)
}

(最大)问题是,它以某种方式在几个键(tip_uuid,user_uuid和deck_uuid)周围添加了引号

怎么来的,我该如何解决?

最佳答案

您正在看到JSON和NSDictionary的NSLog之间的区别。 NSDictionary日志仅引用其中包含“特殊”字符的键,而JSON引用所有内容。同样,正斜杠在JSON中转义,但在NSDictionary日志中不转义。没错,因此没有任何要解决的问题。

关于ios - AFNetworking在JSON响应键中添加引号,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21167317/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com