zepto-lang / json

A JSON library in zepto

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

json

A minimal JSON library in zepto. It is in alpha right now.

Usage

Usage is pretty simple. There is a file called test.zp that shows the most basic usage examples I can think of.

Decoding from JSON could look like this:

(define x (json:parse
            "{ \"unnamed\": 10,
               'lol': {
                 10: 'hello',
                 11: [1, 2]
               }
             }"))
; this will return a hash-map like so:
; #{lol: #{10: hello, 11: (1 2)}, unnamed: 10, }

Encoding to JSON looks like this:

(define x (json:dump #{10 (1 2) 3 "something"}))
; this will return a string like so:
; {10: [1, 2], 3: "something"}

Integrity is preserved, of course.

(define test #{"key" (1 2 3)})
(hash-eqv? test (json:parse (json:dump test))) ; this yields #t

Yay, right?


Have fun!

About

A JSON library in zepto

License:GNU General Public License v2.0