Correctly present empty collections in block-only.

* Fixes #33
This commit is contained in:
Felix Krause 2017-01-10 11:45:55 +01:00
parent 737d326e7a
commit 936df70daa
1 changed files with 10 additions and 2 deletions

View File

@ -554,7 +554,11 @@ proc doPresent(s: var YamlStream, target: PresenterTarget,
"Cannot have sequence as map key in JSON output!")
nextState = dFlowSequenceStart
of psMinimal, psCanonical: nextState = dFlowSequenceStart
of psBlockOnly: nextState = dBlockSequenceItem
of psBlockOnly:
yAssert(not s.finished())
let next = s.peek()
if next.kind == yamlEndSeq: nextState = dFlowSequenceStart
else: nextState = dBlockSequenceItem
if levels.len == 0:
case nextState
@ -605,7 +609,11 @@ proc doPresent(s: var YamlStream, target: PresenterTarget,
raise newException(YamlPresenterJsonError,
"Cannot have map as map key in JSON output!")
nextState = dFlowMapStart
of psBlockOnly: nextState = dBlockMapValue
of psBlockOnly:
yAssert(not s.finished())
let next = s.peek()
if next.kind == yamlEndMap: nextState = dFlowMapStart
else: nextState = dBlockMapValue
if levels.len == 0:
case nextState
of dBlockMapValue: