chicken-users
[Top][All Lists]
Advanced

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

Re: [Chicken-users] Why does the JSON egg map JSON structs to Scheme vec


From: Moritz Heidkamp
Subject: Re: [Chicken-users] Why does the JSON egg map JSON structs to Scheme vectors instead of alists?
Date: Sun, 27 Nov 2011 15:44:13 +0100

Hi Vok,

Vok Vojwo <address@hidden> writes:
> I am a bit confused by the way the JSON egg maps JSON structures to
> Scheme values. The JSON egg maps a structure to a vector:
>
> (use json)
> (with-input-from-string "{\"pi\":3.14,\"e\":2.71}" json-read)
> ;; => #(("pi" . 3.14) ("e" . 2.71))

I agree, this is indeed a strange choice. My guess is that there is no
way to reliably detect whether a list is an alist or not. And since the
json egg maps lists to JSON arrays already, "avectors" were the only
choice left, it seems.

You may be interested in two alternative JSON eggs, namely json-abnf egg
(GPLed) which represents both JSON objects as tagged lists alists
(i.e. they have a symbol `object' their car) and arrays as vectors or
the medea egg (BSD licensed) which uses alists for objects and vectors
for arrays by default but can be parameterized to use whatever
representation you prefer.


Moritz



reply via email to

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