[Top][All Lists]

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

Re: guile-json 2.0.0 released

From: Thompson, David
Subject: Re: guile-json 2.0.0 released
Date: Thu, 13 Dec 2018 12:33:09 -0500

On Thu, Dec 13, 2018 at 12:09 PM John Cowan <address@hidden> wrote:
> Interesting. That's the approach (SXML attribute lists) that I had thought of 
> earlier and abandoned because (a) you cannot search it with assoc and (b) you 
> have to be careful to test in the order "empty JSON array, JSON object, 
> non-empty JSON array", which is annoying.  An approach which solves (a) but 
> not (b) is to use (@) as the marker rather than just @.  An array vs. vector 
> approach of some kind solves (b).
> Another possibility is to continue to use a-lists but to require that the key 
> be a symbol rather than a string.  Since symbols can't appear in JSON 
> representations, this is not subject to conflation, provided the 
> implementation doesn't use a symbol for JSON null.  You'd want a convenience 
> predicate `json-object?` to identify such things.  This solves both (a) and 
> (b) provided you are careful to use symbols as keys internally.

I have also experimented with this approach as well, but the things
living in my brain haven't reached consensus about whether they think
it's better.  It has the nice benefit of not using anything "foreign"
to anyone already familiar with core Scheme data structures, and a
pattern matcher can easily distinguish a JSON object from a JSON
array.  The catch is that '() becomes both the empty array and empty
object so there's no way for the serializer to do the right thing all
the time.  You could introduce a special value for one of those cases,
and hey we're back at square one! ;)

- Dave

reply via email to

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