mirror of
https://github.com/logos-storage/nim-json-rpc.git
synced 2026-01-10 01:23:11 +00:00
Support decoding nil ref object
This commit is contained in:
parent
60c4c9b5f2
commit
a8731e91bc
@ -71,6 +71,9 @@ proc fromJson*(n: JsonNode, argName: string, result: var int) =
|
||||
result = n.getInt()
|
||||
|
||||
proc fromJson*[T: ref object](n: JsonNode, argName: string, result: var T) =
|
||||
if n.kind == JNull:
|
||||
result = nil
|
||||
return
|
||||
n.kind.expect(JObject, argName)
|
||||
result = new T
|
||||
fromJson(n, argName, result[])
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user