【发布时间】:2018-07-10 08:05:42
【问题描述】:
我正在尝试从 JSON 解码(我对我的 HTTP 请求使用 swiftyJSON 和 Alamofire)。 swiftyJsonVar 是我的 JSON 对象
let decoder = JSONDecoder()**
let user = try! decoder.decode([User.self], for:(swiftyJsonVar))**
当我写这个时,我有以下错误
调用中的参数标签不正确(有 ':for:',预期为 ':from:'
所以当我切换到“来自:”时,我有以下错误:
无法将“JSON”类型的值转换为预期的参数类型“数据”*"
当我把从我的请求中获得的数据值转换为 JSON 之前,它工作正常,但是当响应是 JSONArray 时,我不能再这样做了。 感谢您的帮助。
【问题讨论】:
-
解码函数有参数
_ type: _.Type, from: Data -
感谢您的回答!
标签: json swift xcode decode swifty-json