Why does the following code give me the error:
Invalid type in JSON write (_SwiftValue).
The error is thrown on this line:
urlRequest.httpBody = try JSONSerialization.data(withJSONObject: parameters)
Full code:
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
}
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…