You can’t just take and parse this JSON into JavaScript

  • What is the best way to represent large numbers in JSON documents?

  • The JSON standard does not impose any size restrictions on numbers, however, some API authors often represent large numbers as strings in their JSON documents:

    { "foo": "123456789123456789123" }

    This approach allows JS to parse large numbers using the native implementation.

    However, I am absolutely convinced that the correct solution is to use a semantically correct type to represent large numbers in JSON – number. It’s not the fault of the JSON standard and other platforms that the EcmaScript developers were so shortsighted. Exactly for this reason, the TC39 committee is working on the implementation of a new standard, and I have developed the libraries described above.

    Similar Posts

    Leave a Reply

    Your email address will not be published. Required fields are marked *