jsonpath: allow empty paths

This commit is contained in:
Evgeniy Stratonikov 2021-05-11 12:35:28 +03:00
parent 5fc81c787b
commit 28a0d68c05
2 changed files with 5 additions and 0 deletions

View file

@ -38,6 +38,10 @@ const maxNestingDepth = 6
// Get returns substructures of value selected by path.
// The result is always non-nil unless path is invalid.
func Get(path string, value interface{}) ([]interface{}, bool) {
if path == "" {
return []interface{}{value}, true
}
p := pathParser{
depth: maxNestingDepth,
s: path,