diff --git a/parser.go b/parser.go index 669bf0e..41877e3 100644 --- a/parser.go +++ b/parser.go @@ -341,10 +341,6 @@ func (p *parser) extractObject(isSubObject ...bool) (Object, error) { } } - if parenthesisBalanced && len(isSubObject) > 0 && isSubObject[0] { - return object, nil - } - for currentRow := p.scanner.Line; currentRow == lastRow && p.scanner.TokenText() != ""; currentRow = p.scanner.Line { concatenated, err := p.checkAndConcatenate(object, key) if err != nil { @@ -356,6 +352,10 @@ func (p *parser) extractObject(isSubObject ...bool) (Object, error) { } } + if parenthesisBalanced && len(isSubObject) > 0 && isSubObject[0] { + return object, nil + } + for p.scanner.TokenText() == commentToken { p.consumeComment() } diff --git a/parser_test.go b/parser_test.go index 2bea98e..f1f3149 100644 --- a/parser_test.go +++ b/parser_test.go @@ -170,6 +170,14 @@ func TestExtractObject(t *testing.T) { assertDeepEqual(t, got, Object{"a": Object{"b": Int(1)}, "c": Int(2)}) }) + t.Run("extract nested object with the value of unquoted string", func(t *testing.T) { + parser := newParser(strings.NewReader("x {a.b:10cc}")) + parser.advance() + got, err := parser.extractObject() + assertNoError(t, err) + assertDeepEqual(t, got, Object{"x": Object{"a": Object{"b": concatenation{Int(10), String(""), String("cc")}}}}) + }) + t.Run("skip the comments inside objects", func(t *testing.T) { config := `{ # this is a comment