Open masonmark opened 7 years ago
The JSONDecoder.UnevaluatedJSON
mentioned in this post by Itai Ferber (main guy behind Codable
) sounds intriguing... but also far in the future (post-Swift 5).
Also interesting: I read on that same forum that Codable
uses JSONSerialization
under the hood, so it's probably a safe bet that JSONSerialization
will be fairly well-maintained going forward (it's had quite a few issues on Linux over the life of this project, but has steadily advanced...).
Hmm, we have a unit test for our assumption that "JSONSerialization cannot decode an Int64" that I just noticed fails on Swift 4.1 beta and Ubuntu 16.04... which means it can decode that now. I should go back and trace when that assumption became invalid.
I have no idea what my own comment above means: "The JSONSerialization implementation on Linux does not support Int64 regardless of platform, but it does support 64-bit Int on 64-bit platforms." (Did I mean 64-bit Apple platforms? Is Linux JSONSerialization's ability to decode Int64 actually new?)
Dropping support for 32-bit will allow us to use Int for all API data structures (which include 64-bit integers). Why is that desirable? Because it will let us use
JSONSerialization
to decode arbitrary JSON data structures (we will moveCodable
for serialization of objects/structs, and known JSON structures).The
JSONSerialization
implementation on Linux does not supportInt64
regardless of platform, but it does support 64-bitInt
on 64-bit platforms.At this point, I think we still want to use JSONSerialization when receiving an unknown/arbitrary structure as JSON.