Dmitry Gutov writes: > 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 LGTM. Perhaps add a test as well: