forked from mirror/gjson
fix path issue
This commit is contained in:
parent
1b1f52024e
commit
260ef19a2e
26
gjson.go
26
gjson.go
|
@ -137,8 +137,18 @@ func Get(json string, path string) Result {
|
||||||
// underscore characters.
|
// underscore characters.
|
||||||
if path[i] >= '_' {
|
if path[i] >= '_' {
|
||||||
continue
|
continue
|
||||||
} else if path[i] <= '\\' {
|
} else if path[i] == '.' {
|
||||||
if path[i] == '\\' {
|
// append a new part
|
||||||
|
parts = append(parts, part{wild: wild, key: path[s:i]})
|
||||||
|
if wild {
|
||||||
|
wild = false // reset the wild flag
|
||||||
|
}
|
||||||
|
// set the starting index to one past the dot.
|
||||||
|
s = i + 1
|
||||||
|
} else if path[i] == '*' || path[i] == '?' {
|
||||||
|
// set the wild flag to indicate that the part is a wildcard.
|
||||||
|
wild = true
|
||||||
|
} else if path[i] == '\\' {
|
||||||
// go into escape mode. this is a slower path that
|
// go into escape mode. this is a slower path that
|
||||||
// strips off the escape character from the part.
|
// strips off the escape character from the part.
|
||||||
epart := []byte(path[s:i])
|
epart := []byte(path[s:i])
|
||||||
|
@ -170,18 +180,6 @@ func Get(json string, path string) Result {
|
||||||
// append the last part
|
// append the last part
|
||||||
parts = append(parts, part{wild: wild, key: string(epart)})
|
parts = append(parts, part{wild: wild, key: string(epart)})
|
||||||
goto end_parts
|
goto end_parts
|
||||||
} else if path[i] == '.' {
|
|
||||||
// append a new part
|
|
||||||
parts = append(parts, part{wild: wild, key: path[s:i]})
|
|
||||||
if wild {
|
|
||||||
wild = false // reset the wild flag
|
|
||||||
}
|
|
||||||
// set the starting index to one past the dot.
|
|
||||||
s = i + 1
|
|
||||||
} else if path[i] == '*' || path[i] == '?' {
|
|
||||||
// set the wild flag to indicate that the part is a wildcard.
|
|
||||||
wild = true
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// append the last part
|
// append the last part
|
||||||
|
|
Loading…
Reference in New Issue