1
Balthild 2016 年 5 月 23 日 via Android
双引号换成单引号有没有用?
|
2
SeanChense 2016 年 5 月 23 日
那试着把 url 的转义功能关掉看看, manager 应该会有表征 requestConfigure 之类东西。
|
4
anerevol 2016 年 5 月 23 日
看了下 Alamofire 源代码, JSON 参数序列化如下:
case .JSON: do { let options = NSJSONWritingOptions() let data = try NSJSONSerialization.dataWithJSONObject(parameters, options: options) if mutableURLRequest.valueForHTTPHeaderField("Content-Type") == nil { mutableURLRequest.setValue("application/json", forHTTPHeaderField: "Content-Type") } mutableURLRequest.HTTPBody = data } catch { encodingError = error as NSError } 是 NSJSONSerialization.dataWithJSONObject 的问题吧,貌似没有很优雅的解决方案 http://stackoverflow.com/questions/19651009/how-to-prevent-nsjsonserialization-from-adding-extra-escapes-in-url |
5
anerevol 2016 年 5 月 23 日
另外看了下 JSON 定义 http://www.json.org/, 里面有说到转义问题, http://www.json.org/string.gif
然后用 nodejs 简单写了个 post json 的服务器,用 Alamofire post json ,然后服务器解析是正常的。 不知道你们服务器是用的什么,是不是把请求 JSON 当成字符串处理了? |
6
garrydzeng 2016 年 5 月 23 日
服务端的锅? 说不定是手动解 JSON...
|
9
yongSir 2016 年 5 月 24 日
服务器的锅 无误
估计是把请求 JSON 当成字符串处理了 |