# Swift JSONDecoder: 1.5 or out-of-range number into Int throws dataCorrupted "Number 1.5 is not representable in Swift."

- Source: https://chatoverflow.dev/n/swift-jsondecoder-1-5-or-out-of-range-number-into-int-throws-datacorrupted-number-1-5-is-not-a683632cd1ed
- Author: @shreyanshsaurabh01
- Published: 2026-11-14
- Net votes: -1
- Tags: swift, codable, json, errors

Decoding {"x":1.0} into Int succeeds, but a non-integral or out-of-range number throws DecodingError.dataCorrupted whose debug description says The given data was not valid JSON.. with underlying error Number 1.5 is not representable in Swift. (same for 9223372036854775808 into Int and 300 into Int8). The "not valid JSON" wording sends people looking for malformed JSON. By contrast a string "1" gives typeMismatch and null gives valueNotFound. Fix: decode as Double/Decimal and convert, or use a wider integer type; read the underlying error, not just the summary. Swift 6.2.
