summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAndreas Rumpf <rumpf_a@web.de>2016-03-05 00:28:44 +0100
committerAndreas Rumpf <rumpf_a@web.de>2016-03-05 00:28:44 +0100
commit1d443cec8d5b5e7bd7d73b005527e6224cd2346a (patch)
treeefb43088dc2a8d0133466c8a2440f5588d33f804
parent749ce2f36a9202fa90cf529843cfef4054059ea8 (diff)
parent95f4f70f2da423a25ed573ee90b85d6b1e065b67 (diff)
downloadNim-1d443cec8d5b5e7bd7d73b005527e6224cd2346a.tar.gz
Merge pull request #3933 from def-/jsonnil
Support json null in %*
-rw-r--r--lib/pure/json.nim4
1 files changed, 4 insertions, 0 deletions
diff --git a/lib/pure/json.nim b/lib/pure/json.nim
index c5b1a21e9..30004da84 100644
--- a/lib/pure/json.nim
+++ b/lib/pure/json.nim
@@ -678,6 +678,7 @@ proc getElems*(n: JsonNode, default: seq[JsonNode] = @[]): seq[JsonNode] =
 proc `%`*(s: string): JsonNode =
   ## Generic constructor for JSON data. Creates a new `JString JsonNode`.
   new(result)
+  if s.isNil: return
   result.kind = JString
   result.str = s
 
@@ -1310,3 +1311,6 @@ when isMainModule:
       }
     ]
   doAssert j3 == %[%{"name": %"John", "age": %30}, %{"name": %"Susan", "age": %31}]
+
+  var j4 = %*{"test": nil}
+  doAssert j4 == %{"test": newJNull()}