Skip to content

[BUG]: Numbers beyond int64 range are typed as int64/long — generated Go can't unmarshal the sample it was generated from #2931

Description

@schani

Issue Type

quicktype output (number-kind inference from JSON input).

Context (Environment, Version, Language)

Input Format: JSON
Output Language: Go, C# (likely any language that distinguishes integer from floating-point types)

CLI, npm, or app.quicktype.io: CLI (npm)
Version: 25.0.0-pre1 (also reproduces on 24.0.2)

Description

An integer literal in the input JSON that is outside the int64 range is still classified as an integer, so Go gets int64 and C# gets long. The generated code then fails at runtime on the exact sample it was generated from.

Steps to Reproduce

echo '{"big": 9223372036854775807, "bigger": 123456789012345678901234567890}' > big.json
quicktype big.json -l go -t Edge --package main > edge.go

Generated:

Big    int64 `json:"big"`
Bigger int64 `json:"bigger"`   // value is ~1.23e29, max int64 is ~9.2e18

Feeding big.json back into UnmarshalEdge:

json: cannot unmarshal number 123456789012345678901234567890 into Go struct field Edge.bigger of type int64

C# similarly emits public long Bigger { get; set; }.

Expected Behavior

A whole number outside the int64 range should not be classified as an integer — it should fall back to float64/double (or a big-integer type where the target has one), so that generated code can round-trip the input it was derived from.

Related: #2648 (TypeScript BigInt support), #2790 (smarter integer sizing for Rust) — both are enhancements about richer integer types; this issue is narrower: the current classification produces code that fails on its own input.

🤖 Filed with Claude Code

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions