summary refs log tree commit diff stats
path: root/tests
diff options
context:
space:
mode:
authorflywind <43030857+xflywind@users.noreply.github.com>2020-11-04 14:24:40 +0800
committerGitHub <noreply@github.com>2020-11-04 01:24:40 -0500
commit7d640e0943679a772f9595ef3be56fe2158b0912 (patch)
treeb25f64f7baf34f5dc4180650432841d76273c0bd /tests
parentb0e26d8fbffd044aa3f23fc680e6a2e666593399 (diff)
downloadNim-7d640e0943679a772f9595ef3be56fe2158b0912.tar.gz
fix #15835 (#15838)
* fix #15835

* add tests
Diffstat (limited to 'tests')
-rw-r--r--tests/stdlib/t15835.nim17
1 files changed, 17 insertions, 0 deletions
diff --git a/tests/stdlib/t15835.nim b/tests/stdlib/t15835.nim
new file mode 100644
index 000000000..bddfa87aa
--- /dev/null
+++ b/tests/stdlib/t15835.nim
@@ -0,0 +1,17 @@
+import json
+
+type
+  Foo = object
+    ii*: int
+    data*: JsonNode
+
+block:
+  const jt = """{"ii": 123, "data": ["some", "data"]}"""
+  let js = parseJson(jt)
+  discard js.to(Foo)
+
+block:
+  const jt = """{"ii": 123}"""
+  let js = parseJson(jt)
+  doAssertRaises(KeyError):
+    echo js.to(Foo)