of Emacs, for consistency with the common Emacs behavior where
minibuffer history is reserved for past minibuffer inputs.
+** JSON
+
+---
+*** The parser keeps duplicated object keys in alist and plist output.
+A JSON object such as '{"a":1,"a":2}' will now be translated into the
+Lisp values '((a . 1) (a . 2))' or '(:a 1 :a 2)' if alist or plist
+object types are requested.
+
---
-** The JSON parser sometimes signals different types of errors.
+*** The parser sometimes signals different types of errors.
It will now signal 'json-utf8-decode-error' for inputs that are not
correctly UTF-8 encoded.
)
(ert-deftest json-parse-string/object ()
- :expected-result :failed
- ;; FIXME: This currently fails. Should the parser deduplicate keys?
- ;; Never, always, or for alist and plist only?
(let ((input
"{ \"abc\" : [1, 2, true], \"def\" : null, \"abc\" : [9, false] }\n"))
(let ((actual (json-parse-string input)))
(should (equal (cl-sort (map-pairs actual) #'string< :key #'car)
'(("abc" . [9 :false]) ("def" . :null)))))
(should (equal (json-parse-string input :object-type 'alist)
- '((abc . [9 :false]) (def . :null))))
+ '((abc . [1 2 t]) (def . :null) (abc . [9 :false]))))
(should (equal (json-parse-string input :object-type 'plist)
- '(:abc [9 :false] :def :null)))))
+ '(:abc [1 2 t] :def :null :abc [9 :false])))))
(ert-deftest json-parse-string/object-unicode-keys ()
(let ((input "{\"é\":1,\"☃\":2,\"𐌐\":3}"))