json: if-json-null combinator, in the same vein as if-zero, if-empty, etc.

Joe Groff 2010-02-05 14:09:43 -08:00
parent 0844e138fb
commit 78486f0d80
1 changed files with 9 additions and 1 deletions

View File

@ -1,7 +1,15 @@
USING: kernel vocabs.loader ;
IN: json
USE: vocabs.loader
SINGLETON: json-null
: if-json-null ( x if-null else -- )
[ dup json-null? ]
[ [ drop ] prepose ]
[ ] tri* if ; inline
: when-json-null ( x if-null -- ) [ ] if-json-null ; inline
: unless-json-null ( x else -- ) [ ] swap if-json-null ; inline
"json.reader" require
"json.writer" require