[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
bug#40693: 28.0.50; json-encode-alist changes alist
From: |
Dmitry Gutov |
Subject: |
bug#40693: 28.0.50; json-encode-alist changes alist |
Date: |
Sat, 18 Apr 2020 20:29:03 +0300 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 |
Hi Ivan,
thanks for the report.
On 18.04.2020 05:59, Ivan Andrus wrote:
It's late now, but if I have some time in the next few days, I may submit a
patch since it seems like a simple enough change.
How about this one?
diff --git a/lisp/json.el b/lisp/json.el
index 18d7fda882..b65884f913 100644
--- a/lisp/json.el
+++ b/lisp/json.el
@@ -564,9 +564,10 @@ json-encode-alist
"Return a JSON representation of ALIST."
(when json-encoding-object-sort-predicate
(setq alist
- (sort alist (lambda (a b)
- (funcall json-encoding-object-sort-predicate
- (car a) (car b))))))
+ (sort (copy-sequence alist)
+ (lambda (a b)
+ (funcall json-encoding-object-sort-predicate
+ (car a) (car b))))))
(format "{%s%s}"
(json-join
(json--with-indentation