I am attempting to parse the following json data:
Below is my struct:
struct Album: Decodable {
var source: [Sourcet]
enum CodingKeys: String, CodingKey {
case source = "_source"
}
}
struct Sourcet: Decodable {
var nome, endereco, uf, cidade, bairro: String
}
let response = try JSONDecoder().decode(Album.self, from: data)
I continue getting the error:
keyNotFound(CodingKeys(stringValue: "_source", intValue: nil), Swift.DecodingError.Context(codingPath: [], debugDescription: "No value associated with key CodingKeys(stringValue: \"_source\", intValue: nil) (\"_source\").", underlyingError: nil))
Is this due to the json information being an array?.How would I be able to parse this information?