I have following JSON:
[
{
"id": 1,
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
37.5741167,
55.7636592
]
},
"properties": {
"hintContent": "переулок Волков, 13с1",
"balloonContentHeader": "переулок Волков, 13с1"
}
]
I am trying to use JSONDecoder:
struct Point : Codable {
let id: Int
let type: String
let properties: Properties
}
struct Properties : Codable {
let hintContent: String
let balloonContentHeader: String
}
struct Points : Codable {
var data : [Point]
}
func parse(fileName: String) {
let url = Bundle.main.url(forResource: fileName, withExtension: "json")
let data = try? Data(contentsOf: url!)
if let jsonPoints = try? JSONDecoder().decode([Point].self, from: data!) {
print(jsonPoints)
}
}
What is wrong?
}} ]