JSON parsing, written by hand because JSON.parse cannot express the
contract: it collapses 5.0 into 5, destroying the int/double
distinction the type system depends on (a JSON number with a fractional
part never satisfies an int declaration, and str(5.0) is "5.0"
while str(5) is "5").
A number written without a fractional part or exponent becomes int
when it fits the 64-bit range, and double otherwise; anything written
with a fractional part or an exponent is always double.
JSON parsing, written by hand because
JSON.parsecannot express the contract: it collapses5.0into5, destroying the int/double distinction the type system depends on (a JSON number with a fractional part never satisfies anintdeclaration, andstr(5.0)is"5.0"whilestr(5)is"5").A number written without a fractional part or exponent becomes
intwhen it fits the 64-bit range, anddoubleotherwise; anything written with a fractional part or an exponent is alwaysdouble.