aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorPhilipp Stephani2018-09-21 21:50:56 +0200
committerPhilipp Stephani2018-09-21 21:50:56 +0200
commit9f10e1a0eef0dd5572a34a76617d50df0e3dd357 (patch)
treea6e60eb393bc4e00ef74e83bcf1601a8e40461e8 /src
parent7f3877e83405a089b580fe9d0342dc0b6c08cbfc (diff)
downloademacs-9f10e1a0eef0dd5572a34a76617d50df0e3dd357.tar.gz
emacs-9f10e1a0eef0dd5572a34a76617d50df0e3dd357.zip
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')
-rw-r--r--src/json.c10
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)
488 return json_check (json_false ()); 488 return json_check (json_false ());
489 else if (EQ (lisp, Qt)) 489 else if (EQ (lisp, Qt))
490 return json_check (json_true ()); 490 return json_check (json_true ());
491 else if (FIXNUMP (lisp)) 491 else if (INTEGERP (lisp))
492 { 492 {
493 CHECK_TYPE_RANGED_INTEGER (json_int_t, lisp); 493 intmax_t low = TYPE_MINIMUM (json_int_t);
494 return json_check (json_integer (XFIXNUM (lisp))); 494 intmax_t high = TYPE_MAXIMUM (json_int_t);
495 intmax_t value;
496 if (! integer_to_intmax (lisp, &value) || value < low || high < value)
497 args_out_of_range_3 (lisp, make_int (low), make_int (high));
498 return json_check (json_integer (value));
495 } 499 }
496 else if (FLOATP (lisp)) 500 else if (FLOATP (lisp))
497 return json_check (json_real (XFLOAT_DATA (lisp))); 501 return json_check (json_real (XFLOAT_DATA (lisp)));