forked from mirror/gjson
Use no path for simple value queries
This commit is contained in:
parent
00b15d756e
commit
ebf0b3fb77
2
gjson.go
2
gjson.go
|
@ -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
|
||||
|
|
|
@ -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")
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue