mirror of https://github.com/tidwall/gjson.git
parent
6b6af2ad5e
commit
d3a134957c
9
gjson.go
9
gjson.go
|
@ -1728,7 +1728,7 @@ type subSelector struct {
|
||||||
// first character in path is either '[' or '{', and has already been checked
|
// first character in path is either '[' or '{', and has already been checked
|
||||||
// prior to calling this function.
|
// prior to calling this function.
|
||||||
func parseSubSelectors(path string) (sels []subSelector, out string, ok bool) {
|
func parseSubSelectors(path string) (sels []subSelector, out string, ok bool) {
|
||||||
modifer := 0
|
modifier := 0
|
||||||
depth := 1
|
depth := 1
|
||||||
colon := 0
|
colon := 0
|
||||||
start := 1
|
start := 1
|
||||||
|
@ -1743,6 +1743,7 @@ func parseSubSelectors(path string) (sels []subSelector, out string, ok bool) {
|
||||||
}
|
}
|
||||||
sels = append(sels, sel)
|
sels = append(sels, sel)
|
||||||
colon = 0
|
colon = 0
|
||||||
|
modifier = 0
|
||||||
start = i + 1
|
start = i + 1
|
||||||
}
|
}
|
||||||
for ; i < len(path); i++ {
|
for ; i < len(path); i++ {
|
||||||
|
@ -1750,11 +1751,11 @@ func parseSubSelectors(path string) (sels []subSelector, out string, ok bool) {
|
||||||
case '\\':
|
case '\\':
|
||||||
i++
|
i++
|
||||||
case '@':
|
case '@':
|
||||||
if modifer == 0 && i > 0 && (path[i-1] == '.' || path[i-1] == '|') {
|
if modifier == 0 && i > 0 && (path[i-1] == '.' || path[i-1] == '|') {
|
||||||
modifer = i
|
modifier = i
|
||||||
}
|
}
|
||||||
case ':':
|
case ':':
|
||||||
if modifer == 0 && colon == 0 && depth == 1 {
|
if modifier == 0 && colon == 0 && depth == 1 {
|
||||||
colon = i
|
colon = i
|
||||||
}
|
}
|
||||||
case ',':
|
case ',':
|
||||||
|
|
|
@ -1892,6 +1892,9 @@ func TestModifiersInMultipaths(t *testing.T) {
|
||||||
exp = `{"first":"DALE"}`
|
exp = `{"first":"DALE"}`
|
||||||
assert(t, res.Raw == exp)
|
assert(t, res.Raw == exp)
|
||||||
|
|
||||||
|
res = Get(readmeJSON, `{"children":children|@case:upper,"name":name.first,"age":age}`)
|
||||||
|
exp = `{"children":["SARA","ALEX","JACK"],"name":"Tom","age":37}`
|
||||||
|
assert(t, res.Raw == exp)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestIssue141(t *testing.T) {
|
func TestIssue141(t *testing.T) {
|
||||||
|
|
Loading…
Reference in New Issue