Skip to content

Commit

Permalink
Support decoding nil ref object
Browse files Browse the repository at this point in the history
  • Loading branch information
jangko committed Dec 12, 2023
1 parent 60c4c9b commit a8731e9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions json_rpc/jsonmarshal.nim
Original file line number Diff line number Diff line change
Expand Up @@ -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[])
Expand Down

0 comments on commit a8731e9

Please sign in to comment.