Hey I have the following JSON:
{
"monuments": [
{
"name": "Iglesia de Tulyehualco",
"description": "No hay descripción",
"latitude": 19.2544877,
"longitude": -99.012157
},
{
"name": "Casa de Chuyin",
"description": "Casa de Jesús",
"latitude": 119.2563629,
"longitude": -99.0152632
}
]
}
I get the following code to try parse each object but I'm getting the error that type Any has no member 'x'.
func loadMonuments() {
if let path = Bundle.main.path(forResource: "monuments", ofType: "json") {
do {
let data = try Data(contentsOf: URL(fileURLWithPath: path), options: .mappedIfSafe)
let jsonResult = try JSONSerialization.jsonObject(with: data, options: .mutableLeaves)
if let jsonResult = jsonResult as? Dictionary<String, AnyObject>, let monumentsJson = jsonResult["monuments"] as? [Any] {
for m in monumentsJson {
print(m)
}
}
} catch {
// handle error
}
}
}
I want to get each property of the monument.