unofficial mirror of guile-user@gnu.org 
 help / color / mirror / Atom feed
* guile-sjson's first public release (v0.2)!
@ 2017-04-25  4:18 Christopher Allan Webber
  2017-04-25  4:54 ` Marko Rauhamaa
  2017-04-25 13:06 ` Mark Oteiza
  0 siblings, 2 replies; 9+ messages in thread
From: Christopher Allan Webber @ 2017-04-25  4:18 UTC (permalink / raw)
  To: guile-user

[-- Attachment #1: Type: text/plain, Size: 1970 bytes --]

Hello all!  I'm happy to announce the first public release of
guile-sjson!

What's guile-sjson?  Well, it's basically the previous work David
Thompson did on (ice-9 json), but since that seemed to sit without being
merged for a while and I needed it for several projects, I went ahead
and turned it into a module, with Dave's blessing.

Here's the repo:

  https://gitlab.com/dustyweb/guile-sjson

And as for the release:

  https://dustycloud.org/misc/sjson-0.2.tar.gz
  https://dustycloud.org/misc/sjson-0.2.tar.gz.asc

You can see some more about it on its README:

  https://gitlab.com/dustyweb/guile-sjson/blob/master/README.org

In sum though, it has a nice s-expression based syntax:

  scheme@(guile-user)> (define a-horse
                        '(@ ("name" "buttercup")
                            ("age" 6)
                            ("animal" "horse")
                            ("noise" "neigh!")
                            ("food" ("carrot" "oats"))))
                            scheme@(guile-user)> (json-pprint a-horse)
  {
    "name": "buttercup",
    "age": 6,
    "animal": "horse",
    "noise": "neigh!",
    "food": [
      "carrot",
      "oats"
    ]
  }

However, since I'm using this for some fancy linked data stuff using
json-ld, linear access on the hashmaps wasn't great.  No problem!  I
bundled Andy Wingo's fash.scm in the package:

  scheme@(guile-user)> (read-json-from-string "{\"some-key\": \"some-value\"}"
                                              #:use-fash #t)
  $2 = #<fash ((some-key . some-value))>

This also means that since there isn't any other package of fash.scm
right now that I know of, guile-sjson is also a reasonable if roundabout
way to get fashes :)

Anyway, there are also some useful utilities for slicing and dicing
json objects in (sjson utils), so check those out also!

And right after this email, I'm going to submit this to Guix, so
hopefully it'll be in Guix soon as well!

Happy hacking!
 - Chris

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 832 bytes --]

^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: guile-sjson's first public release (v0.2)!
  2017-04-25  4:18 guile-sjson's first public release (v0.2)! Christopher Allan Webber
@ 2017-04-25  4:54 ` Marko Rauhamaa
  2017-04-26  4:03   ` Christopher Allan Webber
  2017-04-25 13:06 ` Mark Oteiza
  1 sibling, 1 reply; 9+ messages in thread
From: Marko Rauhamaa @ 2017-04-25  4:54 UTC (permalink / raw)
  To: Christopher Allan Webber; +Cc: guile-user

Christopher Allan Webber <cwebber@dustycloud.org>:

> In sum though, it has a nice s-expression based syntax:
>
>   scheme@(guile-user)> (define a-horse
>                         '(@ ("name" "buttercup")
>                             ("age" 6)
>                             ("animal" "horse")
>                             ("noise" "neigh!")
>                             ("food" ("carrot" "oats"))))

Hm, how about:

   (define a-horse
           '((name . "buttercup")
             (age . 6)
             (animal . "horse")
             (noise . "neigh!")
             (food . #("carrot" "oats"))))


Marko



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: guile-sjson's first public release (v0.2)!
  2017-04-25  4:18 guile-sjson's first public release (v0.2)! Christopher Allan Webber
  2017-04-25  4:54 ` Marko Rauhamaa
@ 2017-04-25 13:06 ` Mark Oteiza
  2017-04-26  3:55   ` Christopher Allan Webber
  1 sibling, 1 reply; 9+ messages in thread
From: Mark Oteiza @ 2017-04-25 13:06 UTC (permalink / raw)
  To: Christopher Allan Webber; +Cc: guile-user


Christopher Allan Webber <cwebber@dustycloud.org> writes:

> Hello all!  I'm happy to announce the first public release of
> guile-sjson!

Congratulations!

> What's guile-sjson?  Well, it's basically the previous work David
> Thompson did on (ice-9 json), but since that seemed to sit without being
> merged for a while and I needed it for several projects, I went ahead
> and turned it into a module, with Dave's blessing.

Sorry if I missed discussion on this, but is there intention to
address the issues that kept (ice-9 json) from being merged?

https://lists.gnu.org/archive/html/guile-devel/2015-09/msg00035.html



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: guile-sjson's first public release (v0.2)!
  2017-04-25 13:06 ` Mark Oteiza
@ 2017-04-26  3:55   ` Christopher Allan Webber
  0 siblings, 0 replies; 9+ messages in thread
From: Christopher Allan Webber @ 2017-04-26  3:55 UTC (permalink / raw)
  To: Mark Oteiza; +Cc: guile-user

Mark Oteiza writes:

> Christopher Allan Webber <cwebber@dustycloud.org> writes:
>
>> Hello all!  I'm happy to announce the first public release of
>> guile-sjson!
>
> Congratulations!
>
>> What's guile-sjson?  Well, it's basically the previous work David
>> Thompson did on (ice-9 json), but since that seemed to sit without being
>> merged for a while and I needed it for several projects, I went ahead
>> and turned it into a module, with Dave's blessing.
>
> Sorry if I missed discussion on this, but is there intention to
> address the issues that kept (ice-9 json) from being merged?
>
> https://lists.gnu.org/archive/html/guile-devel/2015-09/msg00035.html

I did add tests, though not a standard test suite.

I didn't update the exception handling to be any better, I guess I
should do that. :)  I feel like I'm somewhat inadequate when it comes to
doing exceptions nicely in Guile...



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: guile-sjson's first public release (v0.2)!
  2017-04-25  4:54 ` Marko Rauhamaa
@ 2017-04-26  4:03   ` Christopher Allan Webber
  2017-04-26  5:14     ` Marko Rauhamaa
  2017-04-26 13:57     ` Thompson, David
  0 siblings, 2 replies; 9+ messages in thread
From: Christopher Allan Webber @ 2017-04-26  4:03 UTC (permalink / raw)
  To: Marko Rauhamaa; +Cc: guile-user

Marko Rauhamaa writes:

> Christopher Allan Webber <cwebber@dustycloud.org>:
>
>> In sum though, it has a nice s-expression based syntax:
>>
>>   scheme@(guile-user)> (define a-horse
>>                         '(@ ("name" "buttercup")
>>                             ("age" 6)
>>                             ("animal" "horse")
>>                             ("noise" "neigh!")
>>                             ("food" ("carrot" "oats"))))
>
> Hm, how about:
>
>    (define a-horse
>            '((name . "buttercup")
>              (age . 6)
>              (animal . "horse")
>              (noise . "neigh!")
>              (food . #("carrot" "oats"))))
>
>
> Marko

Hm... that's not bad, using vectors for arrays.  It also fixes the
reason I switched it away from simple cons cell style alists...
I was finding pretty-print of such things unreadable:

  scheme@(guile-user)> ,pretty-print '(@ (name . "buttercup")
                                         (age . 6)
                                         (animal . "horse")
                                         (food . ("carrot" "oats"))
                                         (mood-noises . (@ ("frustrated" . "haurrrfff")
                                                           ("happy" . "neiiiigh")
                                                           ("angry" . "*SNORT*"))))
  $7 = 
  (@ (name . "buttercup")
     (age . 6)
     (animal . "horse")
     (food "carrot" "oats")
     (mood-noises
       @
       ("frustrated" . "haurrrfff")
       ("happy" . "neiiiigh")
       ("angry" . "*SNORT*")))

However doing this with vectors as the arrays solves it:

  scheme@(guile-user)> ,pretty-print '((name . "buttercup")
                                       (age . 6)
                                       (animal . "horse")
                                       (food . #("carrot" "oats"))
                                       (mood-noises . (("frustrated" . "haurrrfff")
                                                       ("happy" . "neiiiigh")
                                                       ("angry" . "*SNORT*"))))
  $5 = 
  ((name . "buttercup")
   (age . 6)
   (animal . "horse")
   (food . #("carrot" "oats"))
   (mood-noises
     ("frustrated" . "haurrrfff")
     ("happy" . "neiiiigh")
     ("angry" . "*SNORT*")))

I'd be open to the change... if we're going to do the change, we should
do it now, when I'm pretty much the only user.  I wonder what David
Thompson thinks?



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: guile-sjson's first public release (v0.2)!
  2017-04-26  4:03   ` Christopher Allan Webber
@ 2017-04-26  5:14     ` Marko Rauhamaa
  2017-04-26 14:55       ` Christopher Allan Webber
  2017-04-26 13:57     ` Thompson, David
  1 sibling, 1 reply; 9+ messages in thread
From: Marko Rauhamaa @ 2017-04-26  5:14 UTC (permalink / raw)
  To: Christopher Allan Webber; +Cc: guile-user

Christopher Allan Webber <cwebber@dustycloud.org>:
>   ((name . "buttercup")
>    (age . 6)
>    (animal . "horse")
>    (food . #("carrot" "oats"))
>    (mood-noises
>      ("frustrated" . "haurrrfff")
>      ("happy" . "neiiiigh")
>      ("angry" . "*SNORT*")))
>
> I'd be open to the change... if we're going to do the change, we
> should do it now, when I'm pretty much the only user. I wonder what
> David Thompson thinks?

Another thing: guile-sjson boldly uses Guile's

   null -> #nil

It is of course handy for the purpose but highly Guile-specific. I
wonder if

   null -> #:null

might create less grief down the road.


Marko



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: guile-sjson's first public release (v0.2)!
  2017-04-26  4:03   ` Christopher Allan Webber
  2017-04-26  5:14     ` Marko Rauhamaa
@ 2017-04-26 13:57     ` Thompson, David
  2017-04-26 14:57       ` Christopher Allan Webber
  1 sibling, 1 reply; 9+ messages in thread
From: Thompson, David @ 2017-04-26 13:57 UTC (permalink / raw)
  To: Christopher Allan Webber; +Cc: Guile User

On Wed, Apr 26, 2017 at 12:03 AM, Christopher Allan Webber
<cwebber@dustycloud.org> wrote:

> I'd be open to the change... if we're going to do the change, we should
> do it now, when I'm pretty much the only user.  I wonder what David
> Thompson thinks?

FWIW this is what Racket does, so there is precedent there, but Mark
Weaver and I explicitly avoided doing this with (ice-9 json) because
vectors are 1) imperative and 2) less convenient to process and
generate.  For example, you can no longer use unquote-splicing, which
is unfortunate.  Furthermore, if you have a list of objects that you
want to serialize, you now need to do the extra step of calling
list->vector.  Lists are the more natural data structure in Scheme for
sequences, so Mark and I thought it was best to stick with them rather
than use vectors even though vectors are more array-like.

Hope this helps,

- Dave



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: guile-sjson's first public release (v0.2)!
  2017-04-26  5:14     ` Marko Rauhamaa
@ 2017-04-26 14:55       ` Christopher Allan Webber
  0 siblings, 0 replies; 9+ messages in thread
From: Christopher Allan Webber @ 2017-04-26 14:55 UTC (permalink / raw)
  To: Marko Rauhamaa; +Cc: guile-user

Marko Rauhamaa writes:

> Christopher Allan Webber <cwebber@dustycloud.org>:
>>   ((name . "buttercup")
>>    (age . 6)
>>    (animal . "horse")
>>    (food . #("carrot" "oats"))
>>    (mood-noises
>>      ("frustrated" . "haurrrfff")
>>      ("happy" . "neiiiigh")
>>      ("angry" . "*SNORT*")))
>>
>> I'd be open to the change... if we're going to do the change, we
>> should do it now, when I'm pretty much the only user. I wonder what
>> David Thompson thinks?
>
> Another thing: guile-sjson boldly uses Guile's
>
>    null -> #nil
>
> It is of course handy for the purpose but highly Guile-specific. I
> wonder if
>
>    null -> #:null
>
> might create less grief down the road.
>
>
> Marko

That may be a good idea worth adding.

I filed a bug:
  https://gitlab.com/dustyweb/guile-sjson/issues/3



^ permalink raw reply	[flat|nested] 9+ messages in thread

* Re: guile-sjson's first public release (v0.2)!
  2017-04-26 13:57     ` Thompson, David
@ 2017-04-26 14:57       ` Christopher Allan Webber
  0 siblings, 0 replies; 9+ messages in thread
From: Christopher Allan Webber @ 2017-04-26 14:57 UTC (permalink / raw)
  To: Thompson, David; +Cc: Guile User

Thompson, David writes:

> On Wed, Apr 26, 2017 at 12:03 AM, Christopher Allan Webber
> <cwebber@dustycloud.org> wrote:
>
>> I'd be open to the change... if we're going to do the change, we should
>> do it now, when I'm pretty much the only user.  I wonder what David
>> Thompson thinks?
>
> FWIW this is what Racket does, so there is precedent there, but Mark
> Weaver and I explicitly avoided doing this with (ice-9 json) because
> vectors are 1) imperative and 2) less convenient to process and
> generate.  For example, you can no longer use unquote-splicing, which
> is unfortunate.  Furthermore, if you have a list of objects that you
> want to serialize, you now need to do the extra step of calling
> list->vector.  Lists are the more natural data structure in Scheme for
> sequences, so Mark and I thought it was best to stick with them rather
> than use vectors even though vectors are more array-like.
>
> Hope this helps,
>
> - Dave

I think that's the right call.  It also means having to not rewrite a
lot of my code. ;)

So things will stay as they are there!



^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2017-04-26 14:57 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-04-25  4:18 guile-sjson's first public release (v0.2)! Christopher Allan Webber
2017-04-25  4:54 ` Marko Rauhamaa
2017-04-26  4:03   ` Christopher Allan Webber
2017-04-26  5:14     ` Marko Rauhamaa
2017-04-26 14:55       ` Christopher Allan Webber
2017-04-26 13:57     ` Thompson, David
2017-04-26 14:57       ` Christopher Allan Webber
2017-04-25 13:06 ` Mark Oteiza
2017-04-26  3:55   ` Christopher Allan Webber

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).