help-gnu-emacs
[Top][All Lists]
Advanced

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

Re: Help with list of list object passed to json-encode


From: Tim Landscheidt
Subject: Re: Help with list of list object passed to json-encode
Date: Sun, 29 May 2022 08:43:55 +0000
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)

Kaushal Modi <kaushal.modi@gmail.com> wrote:

> I was experimenting with passing different s-exp objects to
> json-encode, and realized that this fails:

> (json-encode '((foo . ((1 2) (3 4 5)))))

> […]

> But this passes:

> (json-encode '((foo . [(1 2) (3 4 5)])))

> I'd like to understand why it's so.. Or is this a bug?

Probably not.  An association list is just a list of cons
(and thus may also be a list of lists).  Whether to treat it
as a "simple" list or an association list just depends on
the function which the programmer calls on them, there is no
"association list type".  A vector on the other hand is a
different data type and can thus be discerned from (associa-
tion) lists.

Tim




reply via email to

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