[我正在对来自API的JSON数据进行解码,并且我一直在对图像对象进行解码,该对象的键具有整数值,您可以在所附的屏幕截图中看到它,需要任何帮助。Screenshot
Codable
,您可以使用以下模型来解析以上的JSON响应。
struct Room: Decodable {
let roomId: String
let name: String
let images: [String:String]
}
现在,将其解析为,
do { let response = try JSONDecoder().decode([String:Room].self, from: data) print(response) } catch { print(error) }