As a consequence, one has to rely on using NSDictionnary as a generic-enough type, but this feels really clunky, and forces you at some point to use an unhealthy mix of JSONEncoder for when you can know the type at compile-time, and JSONSerialization.dataObject(with)…
All in all, i feel like all the problem stems from the fact the swift stdlib doesnt define something like that :
Am i missing something ?
Even if you did have a JSON enum in the standard library, it wouldn't really be appropriate to use it throughout your code.
When you do that, you'll find that your JSON dictionaries stay contained in a really narrow boundary layer of your system, and don't creep into your whole codebase. The need for a dedicated JSON type drastically reduces from that.
That's what i ended up doing.
In the end i ended up working with NSDictionaries only.