Integers contained in a [String: Any] dictionary are inferred to be booleans instead of integers
marcelvoss opened this issue · comments
first of all, thanks for building this generator. It is a pleasure to use.
While debugging, I stumbled upon a problem with the way freeform dictionary fields (such as
[String: Any]) are being encoded. Where
1 can be valid integer fields, they are being encoded as booleans. Looking at the implementation of AnyCodable.swift, it seems like in these cases Bool is the first (and best match), although not entirely correct. I know it is possible to cast and type check booleans using
NSJSONSerialization and then encode/decode correctly. I'm not sure the same trick also applies to Codable-based serializations though.