aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/json.c14
1 files changed, 2 insertions, 12 deletions
diff --git a/src/json.c b/src/json.c
index 21066d21328..41566f8369b 100644
--- a/src/json.c
+++ b/src/json.c
@@ -559,16 +559,6 @@ json_out_something (json_out_t *jo, Lisp_Object obj)
559 wrong_type_argument (Qjson_value_p, obj); 559 wrong_type_argument (Qjson_value_p, obj);
560} 560}
561 561
562static Lisp_Object
563json_out_to_string (json_out_t *jo)
564{
565 /* FIXME: should this be a unibyte or multibyte string?
566 Right now we make a multibyte string for test compatibility,
567 but we are really encoding so unibyte would make more sense. */
568 ptrdiff_t nchars = jo->size - jo->chars_delta;
569 return make_multibyte_string (jo->buf, nchars, jo->size);
570}
571
572static void 562static void
573json_serialize (json_out_t *jo, Lisp_Object object, 563json_serialize (json_out_t *jo, Lisp_Object object,
574 ptrdiff_t nargs, Lisp_Object *args) 564 ptrdiff_t nargs, Lisp_Object *args)
@@ -596,7 +586,7 @@ json_serialize (json_out_t *jo, Lisp_Object object,
596 586
597DEFUN ("json-serialize", Fjson_serialize, Sjson_serialize, 1, MANY, 587DEFUN ("json-serialize", Fjson_serialize, Sjson_serialize, 1, MANY,
598 NULL, 588 NULL,
599 doc: /* Return the JSON representation of OBJECT as a string. 589 doc: /* Return the JSON representation of OBJECT as a unibyte string.
600 590
601OBJECT is translated as follows: 591OBJECT is translated as follows:
602 592
@@ -629,7 +619,7 @@ usage: (json-serialize OBJECT &rest ARGS) */)
629 specpdl_ref count = SPECPDL_INDEX (); 619 specpdl_ref count = SPECPDL_INDEX ();
630 json_out_t jo; 620 json_out_t jo;
631 json_serialize (&jo, args[0], nargs - 1, args + 1); 621 json_serialize (&jo, args[0], nargs - 1, args + 1);
632 return unbind_to (count, json_out_to_string (&jo)); 622 return unbind_to (count, make_unibyte_string (jo.buf, jo.size));
633} 623}
634 624
635DEFUN ("json-insert", Fjson_insert, Sjson_insert, 1, MANY, 625DEFUN ("json-insert", Fjson_insert, Sjson_insert, 1, MANY,