summary refs log tree commit diff stats
diff options
context:
space:
mode:
-rw-r--r--lib/pure/json.nim8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/pure/json.nim b/lib/pure/json.nim
index 3e8840e47..7b2a0eed6 100644
--- a/lib/pure/json.nim
+++ b/lib/pure/json.nim
@@ -936,6 +936,14 @@ when isMainModule:
     raise newException(EInvalidValue, "That line was expected to fail")
   except EInvalidIndex: echo()
 
+  let passthroughTest = parseJson"""{ "a": [1, 2, 3, 4], "b": "asd" }"""
+  # nil passthrough
+  assert(passthroughTest["doesnt_exist"][1] == nil)
+  assert(passthroughTest["doesnt_exist"]["anything"] == nil)
+  # default param
+  assert(passthroughTest["doesnt_exist",%true].bval)
+  assert(passthroughTest["doesnt_exist"][1,%true].bval)
+
   discard """
   while true:
     var json = stdin.readLine()