For example my JSON looks like so:
{
createdAt = "2018-06-13T12:38:22.987Z"
}
My Struct looks like so:
struct myStruct {
let createdAt: Date
}
Decode like so:
let decoder = JSONDecoder()
decoder.dateDecodingStrategy = .iso8601
When I am decoding I get this error:
failed to decode, dataCorrupted(Swift.DecodingError.Context(codingPath: [CodingKeys(stringValue: "results", intValue: nil), _JSONKey(stringValue: "Index 0", intValue: 0), CodingKeys(stringValue: "createdAt", intValue: nil)], debugDescription: "Expected date string to be ISO8601-formatted.", underlyingError: nil))
I understand it says that the string was expected to be ISO8601 formatted, but isn't it?