From 78486f0d80e7c9b9adb18679f5506cbf6ec9519f Mon Sep 17 00:00:00 2001 From: Joe Groff Date: Fri, 5 Feb 2010 14:09:43 -0800 Subject: [PATCH] json: if-json-null combinator, in the same vein as if-zero, if-empty, etc. --- basis/json/json.factor | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/basis/json/json.factor b/basis/json/json.factor index d7cfc0e5bc..790e85d610 100644 --- a/basis/json/json.factor +++ b/basis/json/json.factor @@ -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