emacs-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

master dbfe3cae2d9 1/3: Update JSON parser test and docs


From: Mattias Engdegård
Subject: master dbfe3cae2d9 1/3: Update JSON parser test and docs
Date: Mon, 1 Apr 2024 11:07:29 -0400 (EDT)

branch: master
commit dbfe3cae2d9497fb14c83f26425f9421d1ef57cb
Author: Mattias Engdegård <mattiase@acm.org>
Commit: Mattias Engdegård <mattiase@acm.org>

    Update JSON parser test and docs
    
    * test/src/json-tests.el (json-parse-string/object):
    Duplicated object keys are now retained in alist and plist output.
    * etc/NEWS: Mention it.
---
 etc/NEWS               | 10 +++++++++-
 test/src/json-tests.el |  7 ++-----
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/etc/NEWS b/etc/NEWS
index e575fc2936e..4b0f148dc5d 100644
--- a/etc/NEWS
+++ b/etc/NEWS
@@ -1721,8 +1721,16 @@ Use a float value for the first argument instead.
 Instead, use 'eshell-process-wait-time', which supports floating-point
 values.
 
+** 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.
 
diff --git a/test/src/json-tests.el b/test/src/json-tests.el
index 628a5a3de57..8b730ef8c90 100644
--- a/test/src/json-tests.el
+++ b/test/src/json-tests.el
@@ -156,9 +156,6 @@
   )
 
 (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)))
@@ -167,9 +164,9 @@
       (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}"))



reply via email to

[Prev in Thread] Current Thread [Next in Thread]