[Top][All Lists]

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

Re: help with guile-json inconsistencies

From: Zelphir Kaltstahl
Subject: Re: help with guile-json inconsistencies
Date: Tue, 11 Dec 2018 09:31:53 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1

On 11.12.18 06:18, Aleix Conchillo Flaqué wrote:
> On Mon, Dec 10, 2018 at 4:38 PM Zelphir Kaltstahl
> <address@hidden> wrote:
>> On 10.12.18 23:16, address@hidden wrote:
>>> Therefore, one fix would be to make Vector instead of List to
>>> corresponds to Json Array, but maybe this change will cause too much
>>> breakage, so I am not sure it is practical.
>>> Another way would be to make some other type other than Alist to
>>> corresponds to Json Object. If we were in Clojure, it would be Hash
>>> Map. I think VHash is a good candidate, but I am not happy with it not
>>> having a read/write syntax (Hash Table has the same problem too) which
>>> makes it not as flexible as Alist.
>> I think that is how it is done in Racket, if I am not mistaken.
> This is how it's done in guile-json as well. A json object corresponds
> to a hash table in guile-json, otherwise it would not be possible to
> work properly internally.
> The question was not how to parse json and represent it in guile (that
> works well), but how to solve an inconsistency when building a json
> object from scheme data types. This was done by converting an alist to
> a hash table, but unfortunately it doesn't work well in all cases. So,
> the solution is that I will remove the conversion from an alist to an
> object, so a user will need to explicitly provide a hash table (e.g.
> using alist->hash-table). 

I think that is a good idea and don't see a problem with having to do
that, as it makes things explicit and I would have expected, that I have
to provide a hash table to get a JSON object out.

> With this change, the bidirectional mapping
> mentioned here will be consistent:
> (without the alist note)
As long as translating back and forth from JSON and guile still results
in the same structure, this seems fine. Translating JSON to Guile and
then writing it back as JSON again should not result in JSON changes.
> Thanks everyone for all the feedback!
> Aleix
Thanks for guile-json!

reply via email to

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