summaryrefslogtreecommitdiff
path: root/lib/zambyte/meta/gerbil.scm
blob: 8d545ef7fdf03302ebfd13164da325125482a11b (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
(import (std text json)
	(scheme hash-table))
(begin
  (define (json-object . pairs)
    (alist->hash-table pairs equal?))

  (define json-list list)
  (define json-null (if #f #f))
  (define json-object? hash-table?)
  (define json-list? list?)

  (define (json-null? obj)
    (eq? obj json-null))

  (define (json-object-contains-key? json key)
    (hash-table-contains? json key))

  (define string->json string->json-object)
  (define json->string json-object->string)

  (define (json-object-ref json key)
    (or (and (json-object-contains-key? json key)
	     (hash-table-ref json key))
	((json-key-not-found))))

  (define json-list-ref list-ref)
  (define json-list-length length)
  (define json-object->alist hash-table->alist)
  (define json-list->list values))