Hi,
It's probably easiest for me to explain my use case:
The application that I work on uses an API which sends down information that looks vaguely like this:
The application itself holds separate caches with rich models referring to "Honda Accord". During parsing, I'd like to deserialize this model into a SimpleCar model, and then perform a lookup in my cache for the richer model, throwing an error if the model is not found.
My feeling is that this should be done during parse time, so I want to be able to add this contextual information to the JSONDecoder. In the current design JSONDecoder is not extensible. What are your thoughts on:
Making JSONDecoder a protocol
Use a protocol extension to provide all of the JSON parsing functionality we have now
Provide a BaseJSONDecoder type implementing JSONDecoder
I'm sketching this out and I don't see a particular reason why we couldn't do this. Another possibility is making JSONDecoder open to subclassing, which I don't think it is (and object is internal).
Hi, It's probably easiest for me to explain my use case: The application that I work on uses an API which sends down information that looks vaguely like this:
The application itself holds separate caches with rich models referring to "Honda Accord". During parsing, I'd like to deserialize this model into a
SimpleCar
model, and then perform a lookup in my cache for the richer model, throwing an error if the model is not found.My feeling is that this should be done during parse time, so I want to be able to add this contextual information to the
JSONDecoder
. In the current designJSONDecoder
is not extensible. What are your thoughts on:JSONDecoder
a protocolBaseJSONDecoder
type implementingJSONDecoder
associatedtype
toJSONDecodable
I'm sketching this out and I don't see a particular reason why we couldn't do this. Another possibility is making
JSONDecoder
open to subclassing, which I don't think it is (andobject
is internal).