Allow non-string json object keys
This commit is contained in:
11
d-/json.scm
11
d-/json.scm
@@ -27,8 +27,8 @@
|
||||
(define-peg-pattern eobj all (and open-cu close-cu))
|
||||
(define-peg-pattern object all (or eobj
|
||||
(and open-cu
|
||||
(* (and string (ignore ":") ++ value comma))
|
||||
(and string (ignore ":") ++ value)
|
||||
(* (and value (ignore ":") ++ value comma))
|
||||
(and value (ignore ":") ++ value)
|
||||
close-cu)))
|
||||
(define-peg-pattern value body (or number boolean string array object))
|
||||
|
||||
@@ -49,9 +49,10 @@
|
||||
(define (parse-object ss)
|
||||
(if (or (null? ss) (null? (cdr ss)))
|
||||
'()
|
||||
(acons (string->symbol (parse-value (car ss)))
|
||||
(parse-value (cadr ss))
|
||||
(parse-object (cddr ss)))))
|
||||
(let ([key (parse-value (car ss))])
|
||||
(acons (if (string? key) (string->symbol key) key)
|
||||
(parse-value (cadr ss))
|
||||
(parse-object (cddr ss))))))
|
||||
|
||||
(define flatwords '(boolean number string array object))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user