emacs-bug-tracker
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[debbugs-tracker] bug#13518: closed (24.2; json-encode fails on list-of-


From: GNU bug Tracking System
Subject: [debbugs-tracker] bug#13518: closed (24.2; json-encode fails on list-of-alists)
Date: Sun, 24 Nov 2013 22:58:01 +0000

Your message dated Mon, 25 Nov 2013 00:57:40 +0200
with message-id <address@hidden>
and subject line Re: bug#13518: 24.2; json-encode fails on list-of-alists
has caused the debbugs.gnu.org bug report #13518,
regarding 24.2; json-encode fails on list-of-alists
to be marked as done.

(If you believe you have received this mail in error, please contact
address@hidden)


-- 
13518: http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13518
GNU Bug Tracking System
Contact address@hidden with problems
--- Begin Message --- Subject: 24.2; json-encode fails on list-of-alists Date: Mon, 21 Jan 2013 15:13:30 +0100
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) "address@hidden" [cons format "%s:%s" json-encode] 5](((a . b)))
  mapcar(#[(cons) "address@hidden" [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



--- End Message ---
--- Begin Message --- Subject: Re: bug#13518: 24.2; json-encode fails on list-of-alists Date: Mon, 25 Nov 2013 00:57:40 +0200 User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3.50 (gnu/linux)
Version: 24.4

Simon Schubert <address@hidden> 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!


--- End Message ---

reply via email to

[Prev in Thread] Current Thread [Next in Thread]