summary refs log tree commit diff stats
path: root/tests/stdlib
diff options
context:
space:
mode:
authorinv2004 <inv2004@gmail.com>2021-01-07 05:09:02 +0300
committerGitHub <noreply@github.com>2021-01-07 03:09:02 +0100
commit04b765c16d4a53c03f8d41c9b9ad97ac4ac8189e (patch)
treea5b7afe5d56aeff82b427db60a44daa77062fd80 /tests/stdlib
parentd34d023da1d7af972366c3af58a144b395964b4c (diff)
downloadNim-04b765c16d4a53c03f8d41c9b9ad97ac4ac8189e.tar.gz
Jsonutils: pass opt for object in object (#16615)
* jsonutils: fromJson forward opt param fix

* jsonutils: object in object test + fix: opt pass
Diffstat (limited to 'tests/stdlib')
-rw-r--r--tests/stdlib/tjsonutils.nim6
1 files changed, 6 insertions, 0 deletions
diff --git a/tests/stdlib/tjsonutils.nim b/tests/stdlib/tjsonutils.nim
index f56c32719..06d01a9fb 100644
--- a/tests/stdlib/tjsonutils.nim
+++ b/tests/stdlib/tjsonutils.nim
@@ -123,6 +123,9 @@ template fn() =
       a: int
       b: string
       c: float
+    type Bar = object
+      foo: Foo
+      boo: string
     var f: seq[Foo]
     try:
       fromJson(f, parseJson """[{"b": "bbb"}]""")
@@ -131,6 +134,9 @@ template fn() =
       doAssert true
     fromJson(f, parseJson """[{"b": "bbb"}]""", Joptions(allowExtraKeys: true, allowMissingKeys: true))
     doAssert f == @[Foo(a: 0, b: "bbb", c: 0.0)]
+    var b: Bar
+    fromJson(b, parseJson """{"foo": {"b": "bbb"}}""", Joptions(allowExtraKeys: true, allowMissingKeys: true))
+    doAssert b == Bar(foo: Foo(a: 0, b: "bbb", c: 0.0))
 
   block testHashSet:
     testRoundtrip(HashSet[string]()): "[]"