when try a json file to decode, with the Jsondecoder().decode i get the errwor:
Thread 7: Fatal error: 'try!' expression unexpectedly raised an error: Swift.DecodingError.typeMismatch(Swift.Array, Swift.DecodingError.Context(codingPath: [], debugDescription: "Expected to decode Array but found a dictionary instead.", underlyingError: nil))
what does the compiler want to tell me and where is the error in Code?
URLSession.shared.dataTask(with: url) { (dataLocation, _, _) in
if let dataLocation = dataLocation {
let JsonData = try! JSONDecoder().decode([LandmarkLocation].self, from: dataLocation)
print(JsonData.count)
}
}
.resume()
I also added the decodable protocol to the LandmarkLocation structure