aboutsummaryrefslogtreecommitdiffstats
path: root/doc
diff options
context:
space:
mode:
authorJoão Távora2018-06-08 02:35:50 +0100
committerJoão Távora2018-06-15 00:13:00 +0100
commit51adab5de24b3ee215fe636aedb7ff91d69a220c (patch)
tree8664618622113e4890c574d07fa2e025424b951b /doc
parent9348039ed45c8e493e8bfef0220249d4d31ef6da (diff)
downloademacs-51adab5de24b3ee215fe636aedb7ff91d69a220c.tar.gz
emacs-51adab5de24b3ee215fe636aedb7ff91d69a220c.zip
Also allow custom false and null when serializing to JSON
* doc/lispref/text.texi (Parsing JSON): Describe new arguments of json-serialize and json-insert. * src/json.c (enum json_object_type, struct json_configuration): Move up in file before first usage. (lisp_to_json_toplevel, lisp_to_json_toplevel_1, lisp_to_json): Accept a struct json_configuration*. (Fjson_serialize, Fjson_insert): Accept multiple args. (json_parse_args): Accept new boolean configure_object_type. * test/src/json-tests.el (json-serialize, json-insert): Update forward decls. (json-parse-with-custom-null-and-false-objects): Add assertions for json-serialize.
Diffstat (limited to 'doc')
-rw-r--r--doc/lispref/text.texi37
1 files changed, 26 insertions, 11 deletions
diff --git a/doc/lispref/text.texi b/doc/lispref/text.texi
index 5b94580827f..bb6ab04a927 100644
--- a/doc/lispref/text.texi
+++ b/doc/lispref/text.texi
@@ -5063,14 +5063,29 @@ JSON. The subobjects within these top-level values can be of any
5063type. Likewise, the parsing functions will only return vectors, 5063type. Likewise, the parsing functions will only return vectors,
5064hashtables, alists, and plists. 5064hashtables, alists, and plists.
5065 5065
5066@defun json-serialize object 5066@defun json-serialize object &rest args
5067This function returns a new Lisp string which contains the JSON 5067This function returns a new Lisp string which contains the JSON
5068representation of @var{object}. 5068representation of @var{object}. The argument @var{args} is a list of
5069keyword/argument pairs. The following keywords are accepted:
5070
5071@table @code
5072
5073@item :null-object
5074The value decides which Lisp object to use to represent the JSON
5075keyword @code{null}. It defaults to the symbol @code{:null}.
5076
5077@item :false-object
5078The value decides which Lisp object to use to represent the JSON
5079keyword @code{false}. It defaults to the symbol @code{:false}.
5080
5081@end table
5082
5069@end defun 5083@end defun
5070 5084
5071@defun json-insert object 5085@defun json-insert object &rest args
5072This function inserts the JSON representation of @var{object} into the 5086This function inserts the JSON representation of @var{object} into the
5073current buffer before point. 5087current buffer before point. @var{args} is interpreted as in
5088@code{json-parse-string}.
5074@end defun 5089@end defun
5075 5090
5076@defun json-parse-string string &rest args 5091@defun json-parse-string string &rest args
@@ -5078,24 +5093,24 @@ This function parses the JSON value in @var{string}, which must be a
5078Lisp string. The argument @var{args} is a list of keyword/argument 5093Lisp string. The argument @var{args} is a list of keyword/argument
5079pairs. The following keywords are accepted: 5094pairs. The following keywords are accepted:
5080 5095
5081@itemize 5096@table @code
5082 5097
5083@item @code{:object-type} 5098@item :object-type
5084The value decides which Lisp object to use for representing the 5099The value decides which Lisp object to use for representing the
5085key-value mappings of a JSON object. It can be either 5100key-value mappings of a JSON object. It can be either
5086@code{hash-table}, the default, to make hashtables with strings as 5101@code{hash-table}, the default, to make hashtables with strings as
5087keys; @code{alist} to use alists with symbols as keys; or @code{plist} 5102keys; @code{alist} to use alists with symbols as keys; or @code{plist}
5088to use plists with keyword symbols as keys. 5103to use plists with keyword symbols as keys.
5089 5104
5090@item @code{:null-object} 5105@item :null-object
5091The value decides which Lisp object to use to represent the JSON 5106The value decides which Lisp object to use to represent the JSON
5092keyword @code{null}. It defaults to the lisp symbol @code{:null}. 5107keyword @code{null}. It defaults to the symbol @code{:null}.
5093 5108
5094@item @code{:false-object} 5109@item :false-object
5095The value decides which Lisp object to use to represent the JSON 5110The value decides which Lisp object to use to represent the JSON
5096keyword @code{false}. It defaults to the lisp symbol @code{:false}. 5111keyword @code{false}. It defaults to the symbol @code{:false}.
5097 5112
5098@end itemize 5113@end table
5099 5114
5100@end defun 5115@end defun
5101 5116