Re: [Chicken-users] Why does the JSON egg map JSON structs to Scheme vectors instead of alists?

2011-11-28 Thread Alan Post
On Sun, Nov 27, 2011 at 06:39:52PM +0100, Moritz Heidkamp wrote: > Vok Vojwo writes: > > I think the Medea egg intends to do it the right way. But it seems to be > > buggy. > > > > And it has a voracious appetite > > It does indeed :-) > > > > Medea fails to parse the data: > > > > (use medea)

Re: [Chicken-users] Why does the JSON egg map JSON structs to Scheme vectors instead of alists?

2011-11-27 Thread Moritz Heidkamp
Moritz Heidkamp writes: > Thanks for the hint. I managed to bisect it down to a Unicode character > in one of the strings ("’"). Looking at medea's test suite I found this: > > ;; (test-read '#("Дҫ") "[\"Дҫ\"]") ; FIXME genturfahi needs utf8 support for > that to work > > So thanks for the remind

Re: [Chicken-users] Why does the JSON egg map JSON structs to Scheme vectors instead of alists?

2011-11-27 Thread Moritz Heidkamp
Vok Vojwo writes: > I think the Medea egg intends to do it the right way. But it seems to be > buggy. > > And it has a voracious appetite It does indeed :-) > Medea fails to parse the data: > > (use medea) > (read-json json) ;; => #f Thanks for the hint. I managed to bisect it down to a Unico

Re: [Chicken-users] Why does the JSON egg map JSON structs to Scheme vectors instead of alists?

2011-11-27 Thread Moritz Heidkamp
John Cowan writes: > They differ in their representation of JSON null, however: json-abnf > uses 'null, whereas medea's default is () the other way around, actually :-) Moritz ___ Chicken-users mailing list Chicken-users@nongnu.org https://lists.nongn

Re: [Chicken-users] Why does the JSON egg map JSON structs to Scheme vectors instead of alists?

2011-11-27 Thread John Cowan
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 list

Re: [Chicken-users] Why does the JSON egg map JSON structs to Scheme vectors instead of alists?

2011-11-27 Thread Vok Vojwo
2011/11/27 Moritz Heidkamp : > > 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

Re: [Chicken-users] Why does the JSON egg map JSON structs to Scheme vectors instead of alists?

2011-11-27 Thread Moritz Heidkamp
Hi Vok, Vok Vojwo 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

Re: [Chicken-users] Why does the JSON egg map JSON structs to Scheme vectors instead of alists?

2011-11-27 Thread Christian Kellermann
* Vok Vojwo [27 14:37]: > 2011/11/27 Christian Kellermann : > > > > My guess is that it makes it possible to write back to json, since > > alists are already used for representing a different datatype. > > But json-write does not accept alists as values. This > > (json-write (vector (cons "x

Re: [Chicken-users] Why does the JSON egg map JSON structs to Scheme vectors instead of alists?

2011-11-27 Thread Daishi Kato
Even though I agree that it should be schemish, it must be consistent. How would you deal with {"1":[2,3],"4":[5,6]} and [["1",2,3],["4",5,6]] that must be distinguished? Furthermore, if we were to change the spec of the json egg, we should be aware with backward compatibility issues. Otherwise,

Re: [Chicken-users] Why does the JSON egg map JSON structs to Scheme vectors instead of alists?

2011-11-27 Thread Vok Vojwo
2011/11/27 Christian Kellermann : > > My guess is that it makes it possible to write back to json, since > alists are already used for representing a different datatype. But json-write does not accept alists as values. This (json-write (vector (cons "x" (list (cons "a" 1) (cons "b" 2) throws

Re: [Chicken-users] Why does the JSON egg map JSON structs to Scheme vectors instead of alists?

2011-11-27 Thread Christian Kellermann
* Vok Vojwo [27 14:16]: > (assoc* (json->alist json) "feed" "title" "$t") > ;; => "Official Google External Developer Events" > > Is there any reason why the JSON egg creates vectors of pairs? > > If not I would suggest to fix it to make it more schemish. I agree with you and I can only gue

[Chicken-users] Why does the JSON egg map JSON structs to Scheme vectors instead of alists?

2011-11-27 Thread Vok Vojwo
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)) This makes it impossible to use the standard Scheme function a