summaryrefslogtreecommitdiff
path: root/coll/jsonpath.go
diff options
context:
space:
mode:
authorDave Henderson <dhenderson@gmail.com>2025-03-09 20:14:46 -0400
committerGitHub <noreply@github.com>2025-03-10 00:14:46 +0000
commitbfa6b9dcef7592e6dd8225aaa0d0ab5aef5b3f84 (patch)
tree7e844defee92dc3af320df20baa6f9b421d4a4c9 /coll/jsonpath.go
parent7942441e61471f578a57910b3aa93636f5a0310d (diff)
chore(refactoring): Refactor/modernizations (#2345)
chore(refactoring): Refactor with modernization refactorings * range over int * replace interface{} with any * replace common map operations with maps.Copy/maps.Clone * simplifying loops with slices.Contains/ContainsFunc * modernize benchmarks with b.Loop * modernize tests with t.Context * use fmt.Appendf * range over strings.SplitSeq * use new stdlib crypto/pbkdf2 package --------- Signed-off-by: Dave Henderson <dhenderson@gmail.com>
Diffstat (limited to 'coll/jsonpath.go')
-rw-r--r--coll/jsonpath.go8
1 files changed, 4 insertions, 4 deletions
diff --git a/coll/jsonpath.go b/coll/jsonpath.go
index 78ec5689..210280b6 100644
--- a/coll/jsonpath.go
+++ b/coll/jsonpath.go
@@ -8,7 +8,7 @@ import (
)
// JSONPath -
-func JSONPath(p string, in interface{}) (interface{}, error) {
+func JSONPath(p string, in any) (any, error) {
jp, err := parsePath(p)
if err != nil {
return nil, fmt.Errorf("couldn't parse JSONPath %s: %w", p, err)
@@ -18,7 +18,7 @@ func JSONPath(p string, in interface{}) (interface{}, error) {
return nil, fmt.Errorf("executing JSONPath failed: %w", err)
}
- var out interface{}
+ var out any
if len(results) == 1 && len(results[0]) == 1 {
v := results[0][0]
out, err = extractResult(v)
@@ -26,7 +26,7 @@ func JSONPath(p string, in interface{}) (interface{}, error) {
return nil, err
}
} else {
- a := []interface{}{}
+ a := []any{}
for _, r := range results {
for _, v := range r {
o, err := extractResult(v)
@@ -54,7 +54,7 @@ func parsePath(p string) (*jsonpath.JSONPath, error) {
return jp, nil
}
-func extractResult(v reflect.Value) (interface{}, error) {
+func extractResult(v reflect.Value) (any, error) {
if v.CanInterface() {
return v.Interface(), nil
}