Skip to content

Commit

Permalink
Use no path for simple value queries
Browse files Browse the repository at this point in the history
  • Loading branch information
tidwall committed Jun 28, 2019
1 parent 00b15d7 commit ebf0b3f
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 1 deletion.
2 changes: 1 addition & 1 deletion gjson.go
Original file line number Diff line number Diff line change
Expand Up @@ -1226,7 +1226,7 @@ func parseArray(c *parseContext, i int, path string) (int, bool) {
if qval.Type == JSON {
res = qval.Get(rp.query.path)
} else {
if rp.query.path != "" && rp.query.path != "_" {
if rp.query.path != "" {
return false
}
res = qval
Expand Down
1 change: 1 addition & 0 deletions gjson_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1850,5 +1850,6 @@ func TestQueryArrayValues(t *testing.T) {
assert(t, Get(json, `a*.#[0="Bob Dylan"]#|#`).String() == "1")
assert(t, Get(json, `a*.#[0="Bob Dylan 2"]#|#`).String() == "0")
assert(t, Get(json, `a*.#[%"John*"]#|#`).String() == "2")
assert(t, Get(json, `a*.#[_%"John*"]#|#`).String() == "0")
assert(t, Get(json, `a*.#[="123"]#|#`).String() == "1")
}

0 comments on commit ebf0b3f

Please sign in to comment.