diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2016-03-05 00:28:44 +0100 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2016-03-05 00:28:44 +0100 |
commit | 1d443cec8d5b5e7bd7d73b005527e6224cd2346a (patch) | |
tree | efb43088dc2a8d0133466c8a2440f5588d33f804 | |
parent | 749ce2f36a9202fa90cf529843cfef4054059ea8 (diff) | |
parent | 95f4f70f2da423a25ed573ee90b85d6b1e065b67 (diff) | |
download | Nim-1d443cec8d5b5e7bd7d73b005527e6224cd2346a.tar.gz |
Merge pull request #3933 from def-/jsonnil
Support json null in %*
-rw-r--r-- | lib/pure/json.nim | 4 |
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()} |