为什么下面的代码会给我错误:
JSON 写入中的类型无效(_ SwiftValue)。
该错误在以下行中引发:
urlRequest.httpBody = try JSONSerialization.data(withJSONObject: parameters)
完整代码:
let parameters:Parameters = ["resource":[
[
"appUserCode":uuidString,
"productNFCode": self.nfCode!,
"status":code,
"applicationKey":appDelegate.api_key
]
]
]
do {
urlRequest.httpBody = try JSONSerialization.data(withJSONObject: parameters)
} catch {
// No-op
}