summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-06-16 23:43:16 +0200
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2011-06-16 23:43:16 +0200
commited136e498bdc4a4c0dda61d53e0a0ad05a51b18d (patch)
tree739593adedb2915b2cf7f97b8118658a33938caf
parent395d8a112550a43c7ee9dcfbadee491d4a1efb8c (diff)
Support arbitrary <dict?> objects as parameter input.
-rw-r--r--json-template.rkt34
1 files changed, 13 insertions, 21 deletions
diff --git a/json-template.rkt b/json-template.rkt
index 7d9f4c9..0629178 100644
--- a/json-template.rkt
+++ b/json-template.rkt
@@ -212,27 +212,19 @@
(define (resolve-path-in-object context path)
(let ([nothing (gensym)])
- (if (null? path)
- (values context #t)
- (cond
- [(hash? context)
- (let ([y (hash-ref context (car path) nothing)])
- (if (eq? y nothing)
- (values #f #f)
- (resolve-path-in-object y (cdr path))))]
- [(list? context)
- (let* ([x (car path)]
- [y (assf (λ (key)
- (or (and (symbol? key)
- (string=? (symbol->string key) x))
- (and (string? key)
- (string=? key x))))
- context)])
- (if y
- (resolve-path-in-object (cdr y) (cdr path))
- (values #f #f)))]
- [else
- (values #f #f)]))))
+ (cond [(null? path)
+ (values context #t)]
+ [(dict? context)
+ (let ([y (dict-ref context
+ (car path)
+ (dict-ref context
+ (string->symbol (car path))
+ nothing))])
+ (if (eq? y nothing)
+ (values #f #f)
+ (resolve-path-in-object y (cdr path))))]
+ [else
+ (values #f #f)])))
(define (find-formatter name)
(cdr (assoc (if (string? name)