I have an API, which is mostly strongly typed, but has some part that has a JSON dictionary, with arbitrary elements, which could be used for debugging purposes. At first I tried to map this to my Decodable type via a property of Dictionary type String: Decodable but this didn't work, because swift needs more type info. I then came up with the attached enum for representing a random JSON structure, sort of similar to what NSJSONSerialization provides (see below).
I assume the JSONDecoder has a representation of this structure already.
Could something like this be obtained from the JSONDecoder somehow?
Suggestion would be let Decoder have a typealias CanonicalStructure = JSONValue and a the singleValueContainer have a decoder.decodeCanonicalStructure() throws ?
Here's my quick idea for such a structure https://gist.github.com/hannesoid/10a35895e4dc5d6f1bb6428f7d4d23a5