GNU bug report logs -
#40693
28.0.50; json-encode-alist changes alist
Previous Next
Reported by: Ivan Andrus <darthandrus <at> gmail.com>
Date: Sat, 18 Apr 2020 03:01:02 UTC
Severity: normal
Tags: fixed, patch
Found in version 28.0.50
Fixed in version 28.1
Done: "Basil L. Contovounesios" <contovob <at> tcd.ie>
Bug is archived. No further changes may be made.
Full log
Message #11 received at 40693 <at> debbugs.gnu.org (full text, mbox):
That's basically what I had in mind, though I was also going to check other json-encode functions (which you may have already done) to make sure they didn't do something similar.
-Ivan
> On Apr 18, 2020, at 11:29 AM, Dmitry Gutov <dgutov <at> yandex.ru> wrote:
>
> 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
This bug report was last modified 5 years and 58 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.