diff options
| author | João Távora | 2018-06-08 02:35:50 +0100 |
|---|---|---|
| committer | João Távora | 2018-06-15 00:13:00 +0100 |
| commit | 51adab5de24b3ee215fe636aedb7ff91d69a220c (patch) | |
| tree | 8664618622113e4890c574d07fa2e025424b951b /doc | |
| parent | 9348039ed45c8e493e8bfef0220249d4d31ef6da (diff) | |
| download | emacs-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.texi | 37 |
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 | |||
| 5063 | type. Likewise, the parsing functions will only return vectors, | 5063 | type. Likewise, the parsing functions will only return vectors, |
| 5064 | hashtables, alists, and plists. | 5064 | hashtables, alists, and plists. |
| 5065 | 5065 | ||
| 5066 | @defun json-serialize object | 5066 | @defun json-serialize object &rest args |
| 5067 | This function returns a new Lisp string which contains the JSON | 5067 | This function returns a new Lisp string which contains the JSON |
| 5068 | representation of @var{object}. | 5068 | representation of @var{object}. The argument @var{args} is a list of |
| 5069 | keyword/argument pairs. The following keywords are accepted: | ||
| 5070 | |||
| 5071 | @table @code | ||
| 5072 | |||
| 5073 | @item :null-object | ||
| 5074 | The value decides which Lisp object to use to represent the JSON | ||
| 5075 | keyword @code{null}. It defaults to the symbol @code{:null}. | ||
| 5076 | |||
| 5077 | @item :false-object | ||
| 5078 | The value decides which Lisp object to use to represent the JSON | ||
| 5079 | keyword @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 |
| 5072 | This function inserts the JSON representation of @var{object} into the | 5086 | This function inserts the JSON representation of @var{object} into the |
| 5073 | current buffer before point. | 5087 | current 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 | |||
| 5078 | Lisp string. The argument @var{args} is a list of keyword/argument | 5093 | Lisp string. The argument @var{args} is a list of keyword/argument |
| 5079 | pairs. The following keywords are accepted: | 5094 | pairs. The following keywords are accepted: |
| 5080 | 5095 | ||
| 5081 | @itemize | 5096 | @table @code |
| 5082 | 5097 | ||
| 5083 | @item @code{:object-type} | 5098 | @item :object-type |
| 5084 | The value decides which Lisp object to use for representing the | 5099 | The value decides which Lisp object to use for representing the |
| 5085 | key-value mappings of a JSON object. It can be either | 5100 | key-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 |
| 5087 | keys; @code{alist} to use alists with symbols as keys; or @code{plist} | 5102 | keys; @code{alist} to use alists with symbols as keys; or @code{plist} |
| 5088 | to use plists with keyword symbols as keys. | 5103 | to use plists with keyword symbols as keys. |
| 5089 | 5104 | ||
| 5090 | @item @code{:null-object} | 5105 | @item :null-object |
| 5091 | The value decides which Lisp object to use to represent the JSON | 5106 | The value decides which Lisp object to use to represent the JSON |
| 5092 | keyword @code{null}. It defaults to the lisp symbol @code{:null}. | 5107 | keyword @code{null}. It defaults to the symbol @code{:null}. |
| 5093 | 5108 | ||
| 5094 | @item @code{:false-object} | 5109 | @item :false-object |
| 5095 | The value decides which Lisp object to use to represent the JSON | 5110 | The value decides which Lisp object to use to represent the JSON |
| 5096 | keyword @code{false}. It defaults to the lisp symbol @code{:false}. | 5111 | keyword @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 | ||