Fixes for recent compiler changes.
This commit is contained in:
parent
d30928a97e
commit
de62dc27fc
1 changed files with 18 additions and 17 deletions
|
|
@ -8,21 +8,22 @@
|
||||||
|
|
||||||
import json
|
import json
|
||||||
|
|
||||||
when not defined(`{}`):
|
when NimrodPatch <= 4 and NimrodMinor == 9:
|
||||||
proc `{}`*(node: PJsonNode, key: string): PJsonNode =
|
when not defined(`{}`):
|
||||||
## Transverses the node and gets the given value. If any of the
|
proc `{}`*(node: PJsonNode, key: string): PJsonNode =
|
||||||
## names does not exist, returns nil
|
## Transverses the node and gets the given value. If any of the
|
||||||
result = node
|
## names does not exist, returns nil
|
||||||
if isNil(node): return nil
|
result = node
|
||||||
result = result[key]
|
if isNil(node): return nil
|
||||||
|
result = result[key]
|
||||||
|
|
||||||
when not defined(`{}=`):
|
when not defined(`{}=`):
|
||||||
proc `{}=`*(node: PJsonNode, names: varargs[string], value: PJsonNode) =
|
proc `{}=`*(node: PJsonNode, names: varargs[string], value: PJsonNode) =
|
||||||
## Transverses the node and tries to set the value at the given location
|
## Transverses the node and tries to set the value at the given location
|
||||||
## to `value` If any of the names are missing, they are added
|
## to `value` If any of the names are missing, they are added
|
||||||
var node = node
|
var node = node
|
||||||
for i in 0..(names.len-2):
|
for i in 0..(names.len-2):
|
||||||
if isNil(node[names[i]]):
|
if isNil(node[names[i]]):
|
||||||
node[names[i]] = newJObject()
|
node[names[i]] = newJObject()
|
||||||
node = node[names[i]]
|
node = node[names[i]]
|
||||||
node[names[names.len-1]] = value
|
node[names[names.len-1]] = value
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue