Pircate/CleanJSON

Fails on decoding large Double

VasilyKrainov opened this issue · 0 comments

This code makes the exception:

let str = "10000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
let data = str.data(using: .utf8)!
let decoder = CleanJSONDecoder()
do {
  let value = try decoder.decode(Double.self, from: data)
  print("OK = \(value)")
} catch {
  print("Error = \(error)")
}

If you remove one of zeroes in "str" then the decoding will be OK. So the limit is 1e165, after which the decoding fails regardless of Double type can really fit.