我试图低于JSON
和Key
的{{1}}结果并将其存储到两个单独的数组Value
中。我可以轻松附加键,但不能附加值。显示
错误'AnyObject'无法转换为'String';您是要使用“ as!”吗?强迫沮丧?
JSON键是字符串,但值是Int。如何将Int附加到字符串数组?
(keyArray and valuesArray)
我尝试了
{
"status_code": 200,
"message": “ranking”,
"result": {
"cost": 150,
"discount": 25,
“fixon": 0,
"fee": 0,
"check": 0,
"mailing": 20,
}
}
答案 0 :(得分:0)
Dear you can't parse JSON by this way , so you can parse JSON by Decodable
But for pass this error you can add a condition:
if let key = key {
self.processtitle.append(key)
}
if let value = value {
self.price.append("\(value)")
}