summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorDmitry Gutov <dgutov@yandex.ru>2019-04-13 01:33:05 +0300
committerDmitry Gutov <dgutov@yandex.ru>2019-04-13 01:33:42 +0300
commitb41c1ca10fab4ed94e59aea8ad5eae334c2452bd (patch)
tree19e3521522c0924e696bbbae80e90fc466c5a61e /test
parentcc80eeb4a43d2079963de3d181002a6a6b56560d (diff)
downloademacs-b41c1ca10fab4ed94e59aea8ad5eae334c2452bd.tar.gz
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.
Diffstat (limited to 'test')
-rw-r--r--test/src/json-tests.el8
1 files changed, 8 insertions, 0 deletions
diff --git a/test/src/json-tests.el b/test/src/json-tests.el
index 04f91f4abbc..542eec11bf3 100644
--- a/test/src/json-tests.el
+++ b/test/src/json-tests.el
@@ -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)