diff options
author | Philipp Stephani <phst@google.com> | 2018-09-21 21:50:56 +0200 |
---|---|---|
committer | Philipp Stephani <phst@google.com> | 2018-09-21 21:50:56 +0200 |
commit | 9f10e1a0eef0dd5572a34a76617d50df0e3dd357 (patch) | |
tree | a6e60eb393bc4e00ef74e83bcf1601a8e40461e8 /src/json.c | |
parent | 7f3877e83405a089b580fe9d0342dc0b6c08cbfc (diff) | |
download | emacs-9f10e1a0eef0dd5572a34a76617d50df0e3dd357.tar.gz |
Support bignums when serializing JSON
* src/json.c (lisp_to_json): Support bignums.
* test/src/json-tests.el (json-serialize/bignum): New test.
Diffstat (limited to 'src/json.c')
-rw-r--r-- | src/json.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/json.c b/src/json.c index 976783d785c..8b365e3795c 100644 --- a/src/json.c +++ b/src/json.c @@ -488,10 +488,14 @@ lisp_to_json (Lisp_Object lisp, struct json_configuration *conf) return json_check (json_false ()); else if (EQ (lisp, Qt)) return json_check (json_true ()); - else if (FIXNUMP (lisp)) + else if (INTEGERP (lisp)) { - CHECK_TYPE_RANGED_INTEGER (json_int_t, lisp); - return json_check (json_integer (XFIXNUM (lisp))); + intmax_t low = TYPE_MINIMUM (json_int_t); + intmax_t high = TYPE_MAXIMUM (json_int_t); + intmax_t value; + if (! integer_to_intmax (lisp, &value) || value < low || high < value) + args_out_of_range_3 (lisp, make_int (low), make_int (high)); + return json_check (json_integer (value)); } else if (FLOATP (lisp)) return json_check (json_real (XFLOAT_DATA (lisp))); |