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: John Cowan
Subject: Re: [Chicken-users] Why does the JSON egg map JSON structs to Scheme vectors instead of alists?
Date: Sun, 27 Nov 2011 12:16:26 -0500
User-agent: Mutt/1.5.18 (2008-05-17)

Vok Vojwo scripsit:

> I am a bit confused by the way the JSON egg maps JSON structures to
> Scheme values.  [...]
> Is there any reason why the JSON egg creates vectors of pairs?

The problem is that JSON arrays and objects are disjoint, and the egg uses
lists to represent JSON arrays.  Since lists and a-lists are obviously
not disjoint, something else has to be done.

One alternative would be to represent JSON objects as a-lists and
JSON arrays as vectors.  This is the approach taken by the json-abnf
egg, and by the medea egg by default, although medea's representation
is customizable.  They differ in their representation of JSON null,
however: json-abnf uses 'null, whereas medea's default is (); the json
egg uses the undefined value.

I am going to be adding JSON support to my JSO egg when I can steal
a few cycles for it.  JSOs are specially marked a-lists that work
like JavaScript objects, so I will use them to represent JSON objects.
JSON null will be represented by a unique empty JSO.  I haven't yet settled
on the representation of JSON arrays; I might use specially marked JSOs,
or I might use lists (which would require the caller to test for arrays
before objects) or even vectors.

-- 
John Cowan              http://www.ccil.org/~cowan      address@hidden
"After all, would you consider a man without honor wealthy, even if his
Dinar laid end to end would reach from here to the Temple of Toplat?"
"No, I wouldn't", the beggar replied.  "Why is that?" the Master asked.
"A Dinar doesn't go very far these days, Master.        --Kehlog Albran
Besides, the Temple of Toplat is across the street."      The Profit



reply via email to

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