Support decoding nil ref object

This commit is contained in:
jangko 2023-12-12 09:55:21 +07:00
parent 60c4c9b5f2
commit a8731e91bc
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9

View File

@ -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[])