Skip to content

Commit

Permalink
fix flow sequence with map
Browse files Browse the repository at this point in the history
  • Loading branch information
goccy committed Jan 17, 2025
1 parent 4260634 commit 57fc20d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
17 changes: 17 additions & 0 deletions decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -647,6 +647,23 @@ merge:
"v: [A,1,C]",
map[string]interface{}{"v": []interface{}{"A", 1, "C"}},
},
{
"v: [a: b, c: d]",
map[string]any{"v": []any{
map[string]any{"a": "b"},
map[string]any{"c": "d"},
}},
},
{
"v: [{a: b}, {c: d, e: f}]",
map[string]any{"v": []any{
map[string]any{"a": "b"},
map[string]any{
"c": "d",
"e": "f",
},
}},
},

// Block sequence
{
Expand Down
2 changes: 1 addition & 1 deletion parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ func (p *parser) validateMapKeyValueNextToken(ctx *context, keyTk, tk *Token) er
if tk.Column() <= keyTk.Column() {
return nil
}
if ctx.isFlow && tk.Type() == token.CollectEntryType {
if ctx.isFlow && (tk.Type() == token.CollectEntryType || tk.Type() == token.SequenceEndType) {
return nil
}
// a: b
Expand Down

0 comments on commit 57fc20d

Please sign in to comment.