Closed oscbyspro closed 1 week ago
@swift-ci please test
Just some clarification: this solution :tm: only prevents floating-point errors >=(±1).
The fallback Double path still introduces lossy behavior for smaller JSON values that cannot be represented by Double. A proper solution would validate the input String in the parsing step. I suppose ICU doesn't provide integer validation APIs?
try! JSONDecoder().decode(Int64.self, from: "9007199254740991.0".data(using: .utf8)!) // 2^53 - 1, OK
try! JSONDecoder().decode(Int64.self, from: "9007199254740990.5".data(using: .utf8)!) // 2^53 - 2, :(
try! JSONDecoder().decode(Int64.self, from: "9007199254740990.0".data(using: .utf8)!) // 2^53 - 2, OK
LGTM. Thanks!
Hello again, friends!
This patch is the sequel to (#667) that fixes JSONDecoder's Int64 clamping-esque behavior (#613).
It also fixes a bug in _parseJSON5Integer(_:isHex:), which forgot to drop the sign for decimal inputs.