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 #100 received at 40693 <at> debbugs.gnu.org (full text, mbox):
Hi Basil,
"Basil L. Contovounesios" <contovob <at> tcd.ie> writes:
> * lisp/jsonrpc.el (jsonrpc--json-read, jsonrpc--json-encode): Check
> whether native JSON functions are fboundp only once, at load time.
I welcome this small improvement: in fact I had a TODO there to make
something similar. In the TODO i suggested the jsonrpc--json-read could
be a macro. You used `defalias` instead and that's fine. However, I
don't understand the need for the ugly (require 'json), defvar and
declare-function there. Can't we just use sth like `eval-and-compile`
at the top of the file?
> -(defun jsonrpc--json-read ()
> - "Read JSON object in buffer, move point to end of buffer."
> - ;; TODO: I guess we can make these macros if/when jsonrpc.el
> - ;; goes into Emacs core.
> - (cond ((fboundp 'json-parse-buffer) (json-parse-buffer
> - :object-type 'plist
> - :null-object nil
> - :false-object :json-false))
> - (t (let ((json-object-type 'plist))
> - (json-read)))))
> +(defalias 'jsonrpc--json-read
> + (if (fboundp 'json-parse-buffer)
> + (lambda ()
> + (json-parse-buffer :object-type 'plist
> + :null-object nil
> + :false-object :json-false))
> + (require 'json)
> + (defvar json-object-type)
> + (declare-function json-read "json" ())
> + (lambda ()
> + (let ((json-object-type 'plist))
> + (json-read))))
> + "Read JSON object in buffer, move point to end of buffer.")
Thanks,
João
This bug report was last modified 5 years and 57 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.