Skip to content

Commit ddbc2b9

Browse files
committed
fixed error when load null ref as suggested by @gabbhack, closes #8
1 parent 30afca8 commit ddbc2b9

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

sam.nim

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -84,9 +84,10 @@ proc loads(target: var any, m: Mapper, pos = 0) =
8484
loads(t, m, pos)
8585
target = some(t)
8686
elif target is ref:
87-
if target == nil:
88-
new(target)
89-
loads(target[], m, pos)
87+
if m.tokens[pos].getValue(m.json) != "null":
88+
if target == nil:
89+
new(target)
90+
loads(target[], m, pos)
9091
elif target is object or target is tuple:
9192
when defined(verbose):
9293
debugEcho "object ", m.tokens[pos], " ", getValue(m.tokens[pos], m.json)
@@ -167,8 +168,6 @@ proc loads(target: var any, m: Mapper, pos = 0) =
167168
if $e == value:
168169
target = e
169170
break
170-
elif target is ref:
171-
loads(target[], m, pos)
172171
else:
173172
raise newException(KeyError, "unsupported type: " & $target.type)
174173

sam.nimble

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# Package
22

3-
version = "0.1.16"
3+
version = "0.1.17"
44
author = "Huy Doan"
55
description = "Fast and just works JSON-Binding for Nim"
66
license = "MIT"

0 commit comments

Comments
 (0)