I'm trying to parse a JSON file which contains large numbers:

      "uuid": "c73b470a-5efb-4d53-9ac6-c5f6487f227b",
      "description": "grains on square 64",
      "property": "square",
      "input": {
        "square": 64
      "expected": 9223372036854775808

I'm loading the file into a temp buffer and then I'm calling (json-parse-buffer), but the following error happens:

(json-parse-error "too big integer near '9223372036854775808'" "" 72 41 1992)

Supposedly Emacs supports integers of arbitrary size, but I guess the parser function doesn't support it? Is there any way to properly parse a JSON like this in Emacs?

My Emacs version:

GNU Emacs 28.2 (build 2, x86_64-pc-linux-gnu, GTK+ Version 3.24.20, cairo version 1.16.0) of 2023-03-20

  • 3
    stackoverflow.com/questions/13502398/… - even though the spec does not limit number size, implementations do: a lot use IEEE floats for numbers, limiting the size to approximately 2^53. This seems to be the case here: your number is bigger than that.
    – NickD
    Commented Mar 28, 2023 at 17:06

1 Answer 1


Emacs supports bignums, but presumably libjansson does not (and json-parse-buffer is handing off to that C library to do the heavy lifting). There seems to be an upstream issue for that:

The documentation for the current implementation is:

From those docs, you are limited to either to long or long long integers, depending on the compiler which built the library. A long will be a minimum of 32-bits, and a long long will be a minimum of 64-bits.

I would expect that you're dealing with the latter, and my impression is that a long long tends to be no more than 64-bits, so that's (probably) a maximum of 18446744073709551615 unsigned, or 9223372036854775807 signed (and looking at your data, it's not a coincidence that your example failure is 1 higher than that number).

The older elisp-only (json-read) is happy reading that file, FYI.

(require 'json)
(url-handler-mode 1)
(json-read-file "https://raw.githubusercontent.com/exercism/problem-specifications/f771129746264394c20d3c59ba5053acb9de5f86/exercises/grains/canonical-data.json")

That even works in Emacs 26 (i.e. without bignum support), although in that case numbers larger than most-positive-fixnum are converted to floats.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.