unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Rolando Pereira <rolando_pereira@sapo.pt>
To: Glenn Morris <rgm@gnu.org>
Cc: Rolando Pereira <rolando_pereira@sapo.pt>, 15097@debbugs.gnu.org
Subject: bug#15097: 24.3.50; json.el can't encode lists of lists
Date: Mon, 19 Aug 2013 23:09:10 +0100	[thread overview]
Message-ID: <87eh9pcozd.fsf@sapo.pt> (raw)
In-Reply-To: <es4narsont.fsf@fencepost.gnu.org> (Glenn Morris's message of "Wed, 14 Aug 2013 21:55:50 -0400")

Glenn Morris <rgm@gnu.org> writes:

> Rolando Pereira wrote:
>
>> The function `json-encode' can't encode a list thats composed only of other
>> lists, i.e. the following doesn't work:
>>
>>     (json-encode '((1 2 3))) => Error: (json-key-format 1)
> [...]
>> (ert-should (string= (json-encode '((1 2 3))) "[[1,2,3]]")) ; doesn't work
>
> I have no idea what this stuff is supposed to do, but by inspection it
> treats such arguments as alists and requires that the key be encodable
> as a string. Eg this works
>
> (json-encode '((a 2 3)))   ->    "{\"a\":[2, 3]}"
>
> Your example fails because 1 is encoded as 1, not "1".
>
> Should the answer be "{\"1\":[2, 3]} or "[[1,2,3]]"?

0Personally I was expecting the answer to be "[[1,2,3]]" i.e. turn the
'(1 2 3) list into a list and not an object.

Which, for the purposes of comparison, is similar to what the Lisp
library "cl-json" and the Python "json" library do:

* Common Lisp

CL-USER> (ql:quickload 'cl-json)
[...snip...]
CL-USER> (cl-json:encode-json '((1 2 3)))
[[1,2,3]]
NIL
CL-USER>

* Python

Python 2.7.3 (default, Aug  1 2012, 05:16:07) 
[GCC 4.6.3] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import json
>>> json.dumps([[1,2,3]])
'[[1, 2, 3]]'





  reply	other threads:[~2013-08-19 22:09 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-14 22:44 bug#15097: 24.3.50; json.el can't encode lists of lists Rolando Pereira
2013-08-15  1:55 ` Glenn Morris
2013-08-19 22:09   ` Rolando Pereira [this message]
2013-08-19 22:09   ` Rolando Pereira
2013-08-20 17:04     ` Glenn Morris
2013-08-20 20:16       ` Edward O'Connor
2014-03-23  6:40 ` bug#15097: Wontfix, apparently Daniel Colascione

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/emacs/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87eh9pcozd.fsf@sapo.pt \
    --to=rolando_pereira@sapo.pt \
    --cc=15097@debbugs.gnu.org \
    --cc=rgm@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).