json5 / json5-spec

The JSON5 Data Interchange Format
https://spec.json5.org
MIT License
49 stars 11 forks source link

BigInts #8

Closed download13 closed 5 years ago

download13 commented 5 years ago

Now that bigints are a thing in JS it might be useful to support them in json5.

Example:

{
  bignumber: 485555521235458848521546876812103025,
  bigintaswell: 35n
}
jordanbtucker commented 5 years ago

Thanks for your suggestion.

Since the JSON5 spec is not specific about the data structures used to represent numbers, and does not impose a limit on the length of an integer, your first example is already supported by the spec. Implementations are free to parse large integers as BigInts or equivalent structures depending on the platform. If this is something you would like the JSON5 JavaScript library to do, please create an issue or submit a PR there.

The second example is a violation of the ES5 spec. In an effort to keep JSON5 simple, all features must conform to the ES5 spec.