unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#15097: 24.3.50; json.el can't encode lists of lists
@ 2013-08-14 22:44 Rolando Pereira
  2013-08-15  1:55 ` Glenn Morris
  2014-03-23  6:40 ` bug#15097: Wontfix, apparently Daniel Colascione
  0 siblings, 2 replies; 7+ messages in thread
From: Rolando Pereira @ 2013-08-14 22:44 UTC (permalink / raw)
  To: 15097

Hello all,

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)

If I had an extra "nil" in the topmost list `json-encode' then it works
fine:

    (json-encode '((1 2 3) nil)) => "[[1,2,3],null]"

However if I replace the `nil' with another list then I get the same
error:

    (json-encode '((1 2 3) (4))) => Error: (json-key-format 1)

Here's a small ERT test that should trigger the bug:

    (ert-deftest json-encode-list-of-lists-test ()
      (ert-should (string= (json-encode '(1 2 3)) "[1,2,3]"))              ; works
      (ert-should (string= (json-encode '((1) 2 3)) "[[1],2,3]"))          ; works
      (ert-should (string= (json-encode '((1 2 3))) "[[1,2,3]]"))          ; doesn't work
      (ert-should (string= (json-encode '((1 2 3) nil)) "[[1,2,3],null]")) ; works
      (ert-should (string= (json-encode '((1 2 3) (4))) "[[1,2,3],[4]]"))  ; doesn't work
      )


Best regards,
Rolando Pereira





^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-03-23  6:40 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
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
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

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).