summaryrefslogtreecommitdiff
path: root/src/json.c
diff options
context:
space:
mode:
authorPhilipp Stephani <phst@google.com>2018-09-21 21:50:56 +0200
committerPhilipp Stephani <phst@google.com>2018-09-21 21:50:56 +0200
commit9f10e1a0eef0dd5572a34a76617d50df0e3dd357 (patch)
treea6e60eb393bc4e00ef74e83bcf1601a8e40461e8 /src/json.c
parent7f3877e83405a089b580fe9d0342dc0b6c08cbfc (diff)
downloademacs-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.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)
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)));