Skip to content

eeshugerman/wya-json

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 

Repository files navigation

Write Yourself A JSON

What

This Guile Scheme script parses JSON into native Guile data structures (s-expressions). It's tested under Guile 2.x.

Why

I wrote this purely for educational purposes. It's the first program of any substance that I've written in a lisp.

Acknowledgments

This code is heavily inspired by @aconchillo's guile-json. My process was basically to read the guile-json source until it mostly made sense, then rewrite it "in my own words", consulting the specification given here as needed.

Limitations

Escaped unicode (\uXXXX) is not supported. Otherwise, the intention is to be fully compliant with the spec linked above.

Example

$ cat example.json
{
    "widget": {
        "debug": true,
        "window": {
            "title": "Sample Widget",
            "name": "main_window",
            "size": [500, 500],
            "aspect": -1.5
        },
        "text": {
            "data": "Click Here",
            "size": 36,
            "style": "bold",
            "name": "text1",
        },
    }
}

$ cat example.json | guile -s parser.scm
(("widget"
  ("debug" . #t)
  ("window"
   ("title" . "Sample Widget")
   ("name" . "main_window")
   ("size" . #(500 500))
   ("aspect" . -1.5))
  ("text"
   ("data" . "Click Here")
   ("size" . 36)
   ("style" . "bold")
   ("name" . "text1"))))

About

JSON parser in Guile Scheme

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages