From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Simon Schubert <2@0x2c.org> Newsgroups: gmane.emacs.bugs Subject: bug#13518: 24.2; json-encode fails on list-of-alists Date: Mon, 21 Jan 2013 15:13:30 +0100 Message-ID: <87libmy67p.fsf@0x2c.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1358799125 17307 80.91.229.3 (21 Jan 2013 20:12:05 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 21 Jan 2013 20:12:05 +0000 (UTC) To: 13518@debbugs.gnu.org Original-X-From: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Mon Jan 21 21:12:24 2013 Return-path: Envelope-to: geb-bug-gnu-emacs@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1TxNjC-0007or-5s for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 Jan 2013 21:12:22 +0100 Original-Received: from localhost ([::1]:39935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TxNiu-00013f-Re for geb-bug-gnu-emacs@m.gmane.org; Mon, 21 Jan 2013 15:12:04 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:57720) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TxNiq-00012g-OU for bug-gnu-emacs@gnu.org; Mon, 21 Jan 2013 15:12:03 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TxNio-00026Q-9e for bug-gnu-emacs@gnu.org; Mon, 21 Jan 2013 15:12:00 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38057) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TxNio-00026L-6p for bug-gnu-emacs@gnu.org; Mon, 21 Jan 2013 15:11:58 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.72) (envelope-from ) id 1TxNjr-0005VR-6B for bug-gnu-emacs@gnu.org; Mon, 21 Jan 2013 15:13:03 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Simon Schubert <2@0x2c.org> Original-Sender: debbugs-submit-bounces@debbugs.gnu.org Resent-CC: bug-gnu-emacs@gnu.org Resent-Date: Mon, 21 Jan 2013 20:13:03 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: report 13518 X-GNU-PR-Package: emacs X-GNU-PR-Keywords: X-Debbugs-Original-To: bug-gnu-emacs@gnu.org Original-Received: via spool by submit@debbugs.gnu.org id=B.135879915121115 (code B ref -1); Mon, 21 Jan 2013 20:13:03 +0000 Original-Received: (at submit) by debbugs.gnu.org; 21 Jan 2013 20:12:31 +0000 Original-Received: from localhost ([127.0.0.1]:43519 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from ) id 1TxNjJ-0005UQ-Jp for submit@debbugs.gnu.org; Mon, 21 Jan 2013 15:12:31 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:57910) by debbugs.gnu.org with esmtp (Exim 4.72) (envelope-from <2@0x2c.org>) id 1TxI7u-0005Od-5C for submit@debbugs.gnu.org; Mon, 21 Jan 2013 09:13:31 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <2@0x2c.org>) id 1TxI6p-0001fh-3u for submit@debbugs.gnu.org; Mon, 21 Jan 2013 09:12:26 -0500 Original-Received: from lists.gnu.org ([208.118.235.17]:52546) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <2@0x2c.org>) id 1TxI6p-0001fc-17 for submit@debbugs.gnu.org; Mon, 21 Jan 2013 09:12:23 -0500 Original-Received: from eggs.gnu.org ([208.118.235.92]:41007) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from <2@0x2c.org>) id 1TxI6j-0002fK-OT for bug-gnu-emacs@gnu.org; Mon, 21 Jan 2013 09:12:22 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from <2@0x2c.org>) id 1TxI6h-0001eL-9Q for bug-gnu-emacs@gnu.org; Mon, 21 Jan 2013 09:12:17 -0500 Original-Received: from 0x2c.org ([88.198.39.243]:54361) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from <2@0x2c.org>) id 1TxI6h-0001e9-3d for bug-gnu-emacs@gnu.org; Mon, 21 Jan 2013 09:12:15 -0500 Original-Received: from herb (unknown [IPv6:2a01:2a8:8200:41:224:d7ff:fed2:f98c]) (using TLSv1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (Client did not present a certificate) (Authenticated sender: 2) by 0x2c.org (Postfix) with ESMTPSA id 3128A3DDE1C for ; Mon, 21 Jan 2013 15:12:10 +0100 (CET) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Mailman-Approved-At: Mon, 21 Jan 2013 15:12:27 -0500 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.13 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 140.186.70.43 X-BeenThere: bug-gnu-emacs@gnu.org List-Id: "Bug reports for GNU Emacs, the Swiss army knife of text editors" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Original-Sender: bug-gnu-emacs-bounces+geb-bug-gnu-emacs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.emacs.bugs:70144 Archived-At: 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