I am using Codable protocol and JSONDecoder for decoding JSON that I get from my webservice. And it works really nice. One thing, though, is that I sometimes get Date in different formats, so I want to set custom decoding for this field.
Browsing through SO and net, I found this can be done, but I also have to decode all other fields manually. Since I have many fields, I would like to decode all of them automatically and then just this one field to decode manually.
Is this possible?
EDIT:
I will provide some more info, as it seems this question is making a lot of confusion.
I have JSON that has many fields. My struct Person adopts Codable. I use JSONDecoder like this
let person = try self.jsonDecoder.decode(Person.self, from: data)
Now all fields are set automatically to struct. But sometimes I have one or more fields where I would like to manually decode them. In this case it is just date, which can be in various formats. I would like to use if possible this same line:
let person = try self.jsonDecoder.decode(Person.self, from: data)
where all other fields would be decoded automatically, and just Date would have manual encoding.