mirror of
https://github.com/nim-lang/Nim.git
synced 2026-04-30 03:03:57 +00:00
jsonutils: fromJson forward opt param fix (#16612)
This commit is contained in:
@@ -201,17 +201,17 @@ proc fromJson*[T](a: var T, b: JsonNode, opt = Joptions()) =
|
||||
if b.kind == JNull: a = nil
|
||||
else:
|
||||
a = T()
|
||||
fromJson(a[], b)
|
||||
fromJson(a[], b, opt)
|
||||
elif T is array:
|
||||
checkJson a.len == b.len, $(a.len, b.len, $T)
|
||||
var i = 0
|
||||
for ai in mitems(a):
|
||||
fromJson(ai, b[i])
|
||||
fromJson(ai, b[i], opt)
|
||||
i.inc
|
||||
elif T is seq:
|
||||
a.setLen b.len
|
||||
for i, val in b.getElems:
|
||||
fromJson(a[i], val)
|
||||
fromJson(a[i], val, opt)
|
||||
elif T is object:
|
||||
template fun(key, typ): untyped {.used.} =
|
||||
if b.hasKey key:
|
||||
@@ -237,7 +237,7 @@ proc fromJson*[T](a: var T, b: JsonNode, opt = Joptions()) =
|
||||
checkJson b.kind == JArray, $(b.kind) # we could customize whether to allow JNull
|
||||
var i = 0
|
||||
for val in fields(a):
|
||||
fromJson(val, b[i])
|
||||
fromJson(val, b[i], opt)
|
||||
i.inc
|
||||
checkJson b.len == i, $(b.len, i, $T, b) # could customize
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user