Skip to content

Commit

Permalink
fix: nested field selection path bug, add test
Browse files Browse the repository at this point in the history
  • Loading branch information
danielgtaylor committed Mar 16, 2023
1 parent b15ce8a commit dc54b9a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
2 changes: 1 addition & 1 deletion get.go
Expand Up @@ -503,7 +503,7 @@ func (d *Document) getFields(input any) (any, Error) {
d.parseUntilNoReset(1, '|')
continue
}
if r == ':' {
if r == ':' && open <= 1 {
key = d.buf.String()
d.buf.Reset()
d.skipWhitespace()
Expand Down
6 changes: 6 additions & 0 deletions get_test.go
Expand Up @@ -256,6 +256,12 @@ var getExamples = []struct {
Query: `{body: body.{id, created}, one: headers.one}`,
Go: map[string]any{"body": []any{map[string]any{"id": "a", "created": "2022"}}, "one": 1.0},
},
{
Name: "Field expression nested multi path",
Input: `{"body": [{"id": "a", "created": "2022", "link": "..."}], "headers": {"one": 1, "two": 2}}`,
Query: `{body: body.{id, created: created}, one: headers.one}`,
Go: map[string]any{"body": []any{map[string]any{"id": "a", "created": "2022"}}, "one": 1.0},
},
{
Name: "Field expression with pipe",
Input: `{"foo": "bar", "link": {"id": 1, "verified": true, "tags": ["a", "b"]}}`,
Expand Down

0 comments on commit dc54b9a

Please sign in to comment.