Skip to content

Commit eb9e27d

Browse files
committed
Allow json path to work in objects which are struct based interfaces
1 parent c18d0f0 commit eb9e27d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

selector.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ package jsonpath
33
import (
44
"context"
55
"fmt"
6-
"strconv"
7-
86
"github.com/PaesslerAG/gval"
7+
"reflect"
8+
"strconv"
99
)
1010

1111
//plainSelector evaluate exactly one result
@@ -116,10 +116,19 @@ func visitAll(v interface{}, visit func(key string, v interface{})) {
116116
for k, e := range v {
117117
visit(k, e)
118118
}
119+
case interface{}:
120+
vo := reflect.ValueOf(v)
121+
if vo.Kind() == reflect.Map {
122+
for _, vok := range vo.MapKeys() {
123+
if vok.Kind() == reflect.String || vok.Kind() == reflect.Int {
124+
visit(vok.String(), vo.MapIndex(vok).Interface())
125+
}
126+
}
127+
}
119128
}
120-
121129
}
122130

131+
123132
//[? ]
124133
func filterSelector(filter gval.Evaluable) ambiguousSelector {
125134
return func(c context.Context, r, v interface{}, match ambiguousMatcher) {

0 commit comments

Comments
 (0)