mirror of https://github.com/status-im/NimYAML.git
Fixed JSON module to compile against new Nim API
This commit is contained in:
parent
59d2739b79
commit
a5169230a3
|
@ -126,7 +126,7 @@ proc constructJson*(s: var YamlStream): seq[JsonNode] =
|
||||||
let jsonScalar = jsonFromScalar(event.scalarContent,
|
let jsonScalar = jsonFromScalar(event.scalarContent,
|
||||||
event.scalarTag)
|
event.scalarTag)
|
||||||
levels[levels.high].node.fields.add(
|
levels[levels.high].node.fields.add(
|
||||||
(key: levels[levels.high].key, val: jsonScalar))
|
levels[levels.high].key, jsonScalar)
|
||||||
levels[levels.high].key = nil
|
levels[levels.high].key = nil
|
||||||
if event.scalarAnchor != yAnchorNone:
|
if event.scalarAnchor != yAnchorNone:
|
||||||
anchors[event.scalarAnchor] = jsonScalar
|
anchors[event.scalarAnchor] = jsonScalar
|
||||||
|
@ -145,7 +145,7 @@ proc constructJson*(s: var YamlStream): seq[JsonNode] =
|
||||||
"non-scalar as key not allowed in JSON")
|
"non-scalar as key not allowed in JSON")
|
||||||
else:
|
else:
|
||||||
levels[levels.high].node.fields.add(
|
levels[levels.high].node.fields.add(
|
||||||
(key: levels[levels.high].key, val: level.node))
|
levels[levels.high].key, level.node)
|
||||||
levels[levels.high].key = nil
|
levels[levels.high].key = nil
|
||||||
else:
|
else:
|
||||||
discard # will never happen
|
discard # will never happen
|
||||||
|
@ -170,8 +170,8 @@ proc constructJson*(s: var YamlStream): seq[JsonNode] =
|
||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
levels[levels.high].node.fields.add(
|
levels[levels.high].node.fields.add(
|
||||||
(key: levels[levels.high].key,
|
levels[levels.high].key,
|
||||||
val: anchors[event.aliasTarget]))
|
anchors[event.aliasTarget])
|
||||||
except KeyError:
|
except KeyError:
|
||||||
# we can safely assume that this doesn't happen. It would
|
# we can safely assume that this doesn't happen. It would
|
||||||
# have resulted in a parser error earlier.
|
# have resulted in a parser error earlier.
|
||||||
|
@ -204,4 +204,4 @@ proc loadToJson*(s: Stream): seq[JsonNode] =
|
||||||
except AssertionError: raise
|
except AssertionError: raise
|
||||||
except Exception:
|
except Exception:
|
||||||
# compiler bug: https://github.com/nim-lang/Nim/issues/3772
|
# compiler bug: https://github.com/nim-lang/Nim/issues/3772
|
||||||
assert(false)
|
assert(false)
|
||||||
|
|
Loading…
Reference in New Issue