A friend recently asked me how to decode the following JSON through Swift’s Codable type.
{ "a": 1, "b": "foobar", "option.extra": { "a": 1 }, "option.extra.more": 4 } The problem is that only the first two keys (a and b) are guaranteed to exist, anything aside from that (here everything prefixed with option) is extra and unknown at compile-time. Unknown keys should not be discarded however, they should be decoded into a dictionary for later use, we want a type like this.
...
Read more