GNU bug report logs -
#13518
24.2; json-encode fails on list-of-alists
Previous Next
Reported by: Simon Schubert <2 <at> 0x2c.org>
Date: Mon, 21 Jan 2013 20:13:03 UTC
Severity: normal
Tags: patch
Found in version 24.2
Fixed in version 24.4
Done: Dmitry Gutov <dgutov <at> yandex.ru>
Bug is archived. No further changes may be made.
To add a comment to this bug, you must first unarchive it, by sending
a message to control AT debbugs.gnu.org, with unarchive 13518 in the body.
You can then email your comments to 13518 AT debbugs.gnu.org in the normal way.
Toggle the display of automated, internal messages from the tracker.
Report forwarded
to
bug-gnu-emacs <at> gnu.org
:
bug#13518
; Package
emacs
.
(Mon, 21 Jan 2013 20:13:03 GMT)
Full text and
rfc822 format available.
Acknowledgement sent
to
Simon Schubert <2 <at> 0x2c.org>
:
New bug report received and forwarded. Copy sent to
bug-gnu-emacs <at> gnu.org
.
(Mon, 21 Jan 2013 20:13:03 GMT)
Full text and
rfc822 format available.
Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
json-encode fails to encode a list-of-alists:
(require 'json)
(let* ((mypair (cons 'a 'b))
(myalist (list mypair))
(mylistofalist (list myalist)))
(print (json-encode mylistofalist)))
produces this:
Debugger entered--Lisp error: (wrong-type-argument listp b)
mapconcat(json-encode (a . b) ", ")
json-encode-array((a . b))
json-encode-list((a . b))
json-encode((a . b))
#[(cons) "\301\302\303@!\303A!#\207" [cons format "%s:%s" json-encode] 5](((a . b)))
mapcar(#[(cons) "\301\302\303@!\303A!#\207" [cons format "%s:%s" json-encode] 5] (((a . b))))
json-encode-alist((((a . b))))
json-encode-list((((a . b))))
json-encode((((a . b))))
...
The following function fixes this issue:
(defun json-alist-p (list)
"Non-null if and only if LIST is an alist with simple keys."
(while (consp list)
(setq list (if (and (consp (car list))
(atom (caar list)))
(cdr list)
'not-alist)))
(null list))
cheers,
simon
Reply sent
to
Dmitry Gutov <dgutov <at> yandex.ru>
:
You have taken responsibility.
(Sun, 24 Nov 2013 22:58:01 GMT)
Full text and
rfc822 format available.
Notification sent
to
Simon Schubert <2 <at> 0x2c.org>
:
bug acknowledged by developer.
(Sun, 24 Nov 2013 22:58:02 GMT)
Full text and
rfc822 format available.
Message #10 received at 13518-done <at> debbugs.gnu.org (full text, mbox):
Version: 24.4
Simon Schubert <2 <at> 0x2c.org> writes:
> The following function fixes this issue:
>
> (defun json-alist-p (list)
> "Non-null if and only if LIST is an alist with simple keys."
> (while (consp list)
> (setq list (if (and (consp (car list))
> (atom (caar list)))
> (cdr list)
> 'not-alist)))
> (null list))
Applied, thanks!
bug archived.
Request was from
Debbugs Internal Request <help-debbugs <at> gnu.org>
to
internal_control <at> debbugs.gnu.org
.
(Mon, 23 Dec 2013 12:24:03 GMT)
Full text and
rfc822 format available.
This bug report was last modified 10 years and 136 days ago.
Previous Next
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.