diff options
author | Simen Heggestøyl <simenheg@gmail.com> | 2015-10-03 23:52:36 +0200 |
---|---|---|
committer | Simen Heggestøyl <simenheg@gmail.com> | 2015-10-03 23:52:36 +0200 |
commit | 6b66375133a54ea37106b00786d3a85f7c6d658d (patch) | |
tree | c1430aec49e3610c6db7d6aa082988fbfc159b78 /test/automated/json-tests.el | |
parent | 9a05f0ac953ce19395c7409aed6bdd8db83cebb0 (diff) | |
download | emacs-6b66375133a54ea37106b00786d3a85f7c6d658d.tar.gz emacs-6b66375133a54ea37106b00786d3a85f7c6d658d.tar.bz2 emacs-6b66375133a54ea37106b00786d3a85f7c6d658d.zip |
Maintain ordering of JSON object keys by default
* lisp/json.el (json-object-type): Mention order handling in doc-string.
(json--plist-reverse): New utility function.
(json-read-object): Maintain ordering for alists and plists.
(json-pretty-print): Ensure that ordering is maintained.
* test/automated/json-tests.el (test-json-plist-reverse): New test for
`json--plist-reverse'.
(json-read-simple-alist): Update test to accommodate for changes in
`json-read-object'.
* etc/NEWS: Document the new behavior of the pretty printing functions.
Diffstat (limited to 'test/automated/json-tests.el')
-rw-r--r-- | test/automated/json-tests.el | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/test/automated/json-tests.el b/test/automated/json-tests.el index fd89b7aa994..d1b7a2fa022 100644 --- a/test/automated/json-tests.el +++ b/test/automated/json-tests.el @@ -22,15 +22,22 @@ (require 'ert) (require 'json) +(ert-deftest test-json-plist-reverse () + (should (equal (json--plist-reverse '()) '())) + (should (equal (json--plist-reverse '(:a 1)) '(:a 1))) + (should (equal (json--plist-reverse '(:a 1 :b 2 :c 3)) + '(:c 3 :b 2 :a 1)))) + (ert-deftest json-encode-simple-alist () (should (equal (json-encode '((a . 1) (b . 2))) "{\"a\":1,\"b\":2}"))) (ert-deftest json-read-simple-alist () - (should (equal (json-read-from-string "{\"a\": 1, \"b\": 2}") - '((b . 2) - (a . 1))))) + (let ((json-object-type 'alist)) + (should (equal (json-read-from-string "{\"a\": 1, \"b\": 2}") + '((a . 1) + (b . 2)))))) (ert-deftest json-encode-string-with-special-chars () (should (equal (json-encode-string "a\n\fb") |