If I attempt to decode a large number on a 32-bit device, such as an iPhone 5, I get errors like:
ValueNotConvertible(1472861857112, Swift.Double)
Seems to be because the number overflows, triggers a InternalError.NumberOverflow in the parser, and JSONDecodable cannot convert a String to a Double. I think there are a few workarounds:
Make JSONDecodable's Double extension handle String objects.
Force JSONParser to use Int64 for decoding integral values, always.
Attempt to decode with Int64 on 32-bit architectures if Int decoding overflowed.
If I attempt to decode a large number on a 32-bit device, such as an iPhone 5, I get errors like:
Seems to be because the number overflows, triggers a
InternalError.NumberOverflow
in the parser, andJSONDecodable
cannot convert aString
to aDouble
. I think there are a few workarounds:JSONDecodable
'sDouble
extension handleString
objects.JSONParser
to useInt64
for decoding integral values, always.Int64
on 32-bit architectures ifInt
decoding overflowed.