Skip to content

Commit a24b8d1

Browse files
committed
fix for initial comment in braceless root
1 parent 9be7a46 commit a24b8d1

1 file changed

Lines changed: 6 additions & 2 deletions

File tree

src/hjson_decode.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -589,12 +589,16 @@ static void _readArrayElemEnd(Parser* p) {
589589

590590

591591
static void _readObjectBegin(Parser *p) {
592+
p->vParent.back().val = Value(Type::Map);
593+
592594
if (p->ch == '{') {
593595
_next(p);
596+
p->vParent.back().ciElemBefore = _white(p);
597+
} else {
598+
p->vParent.back().ciElemBefore = p->vParent.back().ciBefore;
599+
p->vParent.back().ciBefore = CommentInfo();
594600
}
595601

596-
p->vParent.back().val = Value(Type::Map);
597-
p->vParent.back().ciElemBefore = _white(p);
598602

599603
if (p->ch == '}' && !(p->vParent.empty() && p->withoutBraces)) {
600604
_setComment(p->vParent.back().val, &Value::set_comment_inside, p, p->vParent.back().ciElemBefore);

0 commit comments

Comments
 (0)