Jsonutils: pass opt for object in object (#16615)
* jsonutils: fromJson forward opt param fix * jsonutils: object in object test + fix: opt pass
This commit is contained in:
parent
d34d023da1
commit
04b765c16d
2 changed files with 7 additions and 1 deletions
|
|
@ -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]()): "[]"
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue