diff options
| author | Philipp Stephani | 2017-12-13 22:41:28 +0100 |
|---|---|---|
| committer | Philipp Stephani | 2017-12-24 13:59:25 +0100 |
| commit | f552a957ada23a7ff182fc1ab94221ced3ed1713 (patch) | |
| tree | 359c39cfc24e3c166984717f73884f6c221d1378 /doc | |
| parent | 3455192777459a08a38b0adb311a76202e29f48d (diff) | |
| download | emacs-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.texi | 10 |
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 |
| 4931 | JSON has only one map type, the object. JSON objects are represented | 4931 | JSON has only one map type, the object. JSON objects are represented |
| 4932 | using Lisp hashtables or alists. | 4932 | using Lisp hashtables or alists. When an alist contains several |
| 4933 | elements with the same key, Emacs uses only the first element for | ||
| 4934 | serialization, in accordance with the behavior of @code{assq}. | ||
| 4933 | 4935 | ||
| 4934 | @end itemize | 4936 | @end itemize |
| 4935 | 4937 | ||
| 4936 | @noindent | 4938 | @noindent |
| 4937 | Note that @code{nil} represents the empty JSON object, @code{@{@}}, | 4939 | Note that @code{nil} is a valid alist and represents the empty JSON |
| 4938 | not @code{null}, @code{false}, or an empty array, all of which are | 4940 | object, @code{@{@}}, not @code{null}, @code{false}, or an empty array, |
| 4939 | different JSON values. | 4941 | all 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 |
| 4942 | functions will signal an error of type @code{wrong-type-argument}. | 4944 | functions will signal an error of type @code{wrong-type-argument}. |