mirror of
git://git.sv.gnu.org/emacs.git
synced 2026-04-27 16:51:06 -07:00
Add :array-type option to json-parse-string
* src/json.c (enum json_array_type): New type. (struct json_configuration): New field array_type. (json_parse_args): Rename the last argument. Handle the :array-type keyword argument (bug#32793). (Fjson_parse_string): Update the docstring accordingly. (json_to_lisp): Handle the case of :array-type being `list'. Add a call to 'rarely_quit' inside the loop. (syms_of_json): Define new symbols. (Fjson_serialize, Fjson_insert, Fjson_parse_string) (Fjson_parse_buffer): Update the config struct initializers.
This commit is contained in:
parent
cc80eeb4a4
commit
b41c1ca10f
3 changed files with 78 additions and 13 deletions
|
|
@ -117,6 +117,14 @@
|
|||
(should (equal (json-parse-string input :object-type 'plist)
|
||||
'(:abc [9 :false] :def :null)))))
|
||||
|
||||
(ert-deftest json-parse-string/array ()
|
||||
(skip-unless (fboundp 'json-parse-string))
|
||||
(let ((input "[\"a\", 1, [\"b\", 2]]"))
|
||||
(should (equal (json-parse-string input)
|
||||
["a" 1 ["b" 2]]))
|
||||
(should (equal (json-parse-string input :array-type 'list)
|
||||
'("a" 1 ("b" 2))))))
|
||||
|
||||
(ert-deftest json-parse-string/string ()
|
||||
(skip-unless (fboundp 'json-parse-string))
|
||||
(should-error (json-parse-string "[\"formfeed\f\"]") :type 'json-parse-error)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue