aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorPhilipp Stephani2017-12-13 22:41:28 +0100
committerPhilipp Stephani2017-12-24 13:59:25 +0100
commitf552a957ada23a7ff182fc1ab94221ced3ed1713 (patch)
tree359c39cfc24e3c166984717f73884f6c221d1378 /doc
parent3455192777459a08a38b0adb311a76202e29f48d (diff)
downloademacs-f552a957ada23a7ff182fc1ab94221ced3ed1713.tar.gz
emacs-f552a957ada23a7ff182fc1ab94221ced3ed1713.zip
Accept alists when serializing JSON
* src/json.c (lisp_to_json_toplevel_1): Also accept alists representing objects. * src/json.c (Fjson_serialize): Update docstring. * test/src/json-tests.el (json-serialize/object): Add unit tests for serializing alists. * doc/lispref/text.texi (Parsing JSON): Document that serialization functions accept alists.
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/text.texi10
1 files changed, 6 insertions, 4 deletions
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index 561ad804344..7a1983641fd 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -4929,14 +4929,16 @@ represented using Lisp vectors.
4929 4929
4930@item 4930@item
4931JSON has only one map type, the object. JSON objects are represented 4931JSON has only one map type, the object. JSON objects are represented
4932using Lisp hashtables or alists. 4932using Lisp hashtables or alists. When an alist contains several
4933elements with the same key, Emacs uses only the first element for
4934serialization, in accordance with the behavior of @code{assq}.
4933 4935
4934@end itemize 4936@end itemize
4935 4937
4936@noindent 4938@noindent
4937Note that @code{nil} represents the empty JSON object, @code{@{@}}, 4939Note that @code{nil} is a valid alist and represents the empty JSON
4938not @code{null}, @code{false}, or an empty array, all of which are 4940object, @code{@{@}}, not @code{null}, @code{false}, or an empty array,
4939different JSON values. 4941all of which are different JSON values.
4940 4942
4941 If some Lisp object can't be represented in JSON, the serialization 4943 If some Lisp object can't be represented in JSON, the serialization
4942functions will signal an error of type @code{wrong-type-argument}. 4944functions will signal an error of type @code{wrong-type-argument}.