mholt / json-to-go

Translates JSON into a Go type in your browser instantly (original)
https://mholt.github.io/json-to-go/
MIT License
4.51k stars 475 forks source link

function goType(val) returns int64 instead of float64 #80

Open zen37 opened 4 years ago

zen37 commented 4 years ago

If val = 12345678901234567890 or 12345678901234567890.5 float64 should be returned instead of int64.

case "number": if (val % 1 === 0) { if (val > -2147483648 && val < 2147483647) return "int"; else return "int64"; } else return "float64";

should be replaced with

case "number": if (val % 1 === 0) { if (val > -2147483648 && val < 2147483647) return "int"; else if (val > -9223372036854775808 && val < 9223372036854775807) return "int64"; } return "float64";