diff --git a/private/fastparse.nim b/private/fastparse.nim index a01f6bc..26fa1af 100644 --- a/private/fastparse.nim +++ b/private/fastparse.nim @@ -1076,7 +1076,11 @@ proc fastparse*(tagLib: TagLibrary, s: Stream): YamlStream = anchor = yAnchorNone level.kind = fplMapKey of fplMapKey: - discard + if tag != yTagQuestionmark or anchor != yAnchorNone: + yield scalarEvent("", tag, anchor) + tag = yTagQuestionmark + anchor = yAnchorNone + yield scalarEvent("", tag, anchor) of fplSequence: raiseError("Unexpected token (expected ']')", lexer.bufpos) of fplUnknown, fplScalar: @@ -1088,7 +1092,10 @@ proc fastparse*(tagLib: TagLibrary, s: Stream): YamlStream = level = ancestry.pop() case level.kind of fplSequence: - yield endSeqEvent() + if tag != yTagQuestionmark or anchor != yAnchorNone: + yield scalarEvent("", tag, anchor) + tag = yTagQuestionmark + anchor = yAnchorNone of fplMapKey, fplMapValue: raiseError("Unexpected token (expected '}')", lexer.bufpos) of fplUnknown, fplScalar: diff --git a/private/json.nim b/private/json.nim index ca5968b..d48a695 100644 --- a/private/json.nim +++ b/private/json.nim @@ -124,6 +124,7 @@ proc constructJson*(s: YamlStream): seq[JsonNode] = levels[levels.high].node.elems.add(level.node) of JObject: if isNil(levels[levels.high].key): + echo level.node.pretty() raise newException(ValueError, "non-scalar as key not allowed in JSON") else: