Commit 2475687d authored by Eli Zaretskii's avatar Eli Zaretskii

Improve documentation changes of a recent commit

* doc/lispref/text.texi (Parsing JSON): Improve wording of the
documentation of 'json-parse-string' and 'json-parse-buffer'.
* src/json.c (Fjson_parse_string, Fjson_parse_buffer): Doc fix.
(Bug#34763)
parent 7ddd08bd
Pipeline #1264 failed with stage
in 51 minutes and 38 seconds
...@@ -5156,8 +5156,11 @@ as in @code{json-parse-string}. ...@@ -5156,8 +5156,11 @@ as in @code{json-parse-string}.
@defun json-parse-string string &rest args @defun json-parse-string string &rest args
This function parses the JSON value in @var{string}, which must be a This function parses the JSON value in @var{string}, which must be a
Lisp string. The argument @var{args} is a list of keyword/argument Lisp string. If @var{string} doesn't contain a valid JSON object,
pairs. The following keywords are accepted: this function signals the @code{json-parse-error} error.
The argument @var{args} is a list of keyword/argument pairs. The
following keywords are accepted:
@table @code @table @code
@item :object-type @item :object-type
...@@ -5186,9 +5189,9 @@ keyword @code{false}. It defaults to the symbol @code{:false}. ...@@ -5186,9 +5189,9 @@ keyword @code{false}. It defaults to the symbol @code{:false}.
@defun json-parse-buffer &rest args @defun json-parse-buffer &rest args
This function reads the next JSON value from the current buffer, This function reads the next JSON value from the current buffer,
starting at point. It moves point to the position immediately after starting at point. It moves point to the position immediately after
the value if a value could be read and converted to Lisp; otherwise it the value if contains a valid JSON object; otherwise it signals the
doesn't move point. The arguments @var{args} are interpreted as in @code{json-parse-error} error and doesn't move point. The arguments
@code{json-parse-string}. @var{args} are interpreted as in @code{json-parse-string}.
@end defun @end defun
@node JSONRPC @node JSONRPC
......
...@@ -948,23 +948,22 @@ json_to_lisp (json_t *json, struct json_configuration *conf) ...@@ -948,23 +948,22 @@ json_to_lisp (json_t *json, struct json_configuration *conf)
DEFUN ("json-parse-string", Fjson_parse_string, Sjson_parse_string, 1, MANY, DEFUN ("json-parse-string", Fjson_parse_string, Sjson_parse_string, 1, MANY,
NULL, NULL,
doc: /* Parse the JSON STRING into a Lisp object. doc: /* Parse the JSON STRING into a Lisp object.
This is essentially the reverse operation of `json-serialize', which This is essentially the reverse operation of `json-serialize', which
see. The returned object will be a vector, hashtable, alist, or see. The returned object will be a vector, list, hashtable, alist, or
plist. Its elements will be the JSON null value, the JSON false plist. Its elements will be the JSON null value, the JSON false
value, t, numbers, strings, or further vectors, hashtables, alists, or value, t, numbers, strings, or further vectors, hashtables, alists, or
plists. If there are duplicate keys in an object, all but the last plists. If there are duplicate keys in an object, all but the last
one are ignored. If STRING doesn't contain a valid JSON object, an one are ignored. If STRING doesn't contain a valid JSON object, this
error of type `json-parse-error' is signaled. The arguments ARGS are function signals an error of type `json-parse-error'.
a list of keyword/argument pairs:
The arguments ARGS are a list of keyword/argument pairs:
The keyword argument `:object-type' specifies which Lisp type is used The keyword argument `:object-type' specifies which Lisp type is used
to represent objects; it can be `hash-table', `alist' or `plist'. It to represent objects; it can be `hash-table', `alist' or `plist'. It
defaults to `hash-table'. defaults to `hash-table'.
The keyword argument `:array-type' specifies which Lisp type is used The keyword argument `:array-type' specifies which Lisp type is used
to represent arrays; it can be `array' or `list'. It defaults to to represent arrays; it can be `array' (the default) or `list'.
`array'.
The keyword argument `:null-object' specifies which object to use The keyword argument `:null-object' specifies which object to use
to represent a JSON null value. It defaults to `:null'. to represent a JSON null value. It defaults to `:null'.
...@@ -1042,9 +1041,32 @@ json_read_buffer_callback (void *buffer, size_t buflen, void *data) ...@@ -1042,9 +1041,32 @@ json_read_buffer_callback (void *buffer, size_t buflen, void *data)
DEFUN ("json-parse-buffer", Fjson_parse_buffer, Sjson_parse_buffer, DEFUN ("json-parse-buffer", Fjson_parse_buffer, Sjson_parse_buffer,
0, MANY, NULL, 0, MANY, NULL,
doc: /* Read JSON object from current buffer starting at point. doc: /* Read JSON object from current buffer starting at point.
This is similar to `json-parse-string', which see. Move point after Move point after the end of the object if parsing was successful.
the end of the object if parsing was successful. On error, point is On error, don't move point.
not moved.
The returned object will be a vector, list, hashtable, alist, or
plist. Its elements will be the JSON null value, the JSON false
value, t, numbers, strings, or further vectors, lists, hashtables,
alists, or plists. If there are duplicate keys in an object, all
but the last one are ignored.
If the current buffer doesn't contain a valid JSON object, the
function signals an error of type `json-parse-error'.
The arguments ARGS are a list of keyword/argument pairs:
The keyword argument `:object-type' specifies which Lisp type is used
to represent objects; it can be `hash-table', `alist' or `plist'. It
defaults to `hash-table'.
The keyword argument `:array-type' specifies which Lisp type is used
to represent arrays; it can be `array' (the default) or `list'.
The keyword argument `:null-object' specifies which object to use
to represent a JSON null value. It defaults to `:null'.
The keyword argument `:false-object' specifies which object to use to
represent a JSON false value. It defaults to `:false'.
usage: (json-parse-buffer &rest args) */) usage: (json-parse-buffer &rest args) */)
(ptrdiff_t nargs, Lisp_Object *args) (ptrdiff_t nargs, Lisp_Object *args)
{ {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment