[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
Re: [Chicken-users] Why does the JSON egg map JSON structs to Scheme vectors instead of alists?
Sun, 27 Nov 2011 12:16:26 -0500
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
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