0
解码JSONArray到特定字段我有此(IMHO低劣)JSON可编码:通过指数
"geometry": {
"type": "Point",
"coordinates": [
6.08235,
44.62117
]
}
我想映射到此struct
,滴阵列2个字段。
struct MMGeometry:Codable {
let type:String
let latitude: Double
let longitude: Double
}
JSONDecoder
能够做到这一点吗?也许使用CodingKey
?
你将不得不要么提供的JSON,然后可以计算从这些属性的布局相匹配的嵌套类型,或者只是覆盖'init(from:Decoder)'手动解码。 –