I have the following struct that represents a JSON:
struct Todo: Codable {
let ID: Int?
let LAST_DT_ADD: String?
let LAST_ID:Int?
}
And when I use decode the same way:
let decoder = JSONDecoder()
do {
let todo = try decoder.decode(Todo.self, from: responseData)
completionHandler(todo, nil)
} catch {
print("error trying to convert data to JSON")
print(error)
completionHandler(nil, error)
}
It decodes correctly, but when I have JSON items in lowercase (for example instead of ID
, LAST_DT_ADD
and LAST_ID
, I have id
, last_dt_add
and last_id
), it is not decoding the object. What do I have to do? How can I support uppercase and lowercase?