From 80d9de6cf9c9a6dd76c76d01dc800c3aafd068b1 Mon Sep 17 00:00:00 2001 From: rakaupuv <50501738+rakaupuv@users.noreply.github.com> Date: Fri, 10 May 2019 13:48:33 -0700 Subject: [PATCH] Update jsonpath.go IMO, when the field is missing in the slice, instead of erring out, ignoring that and continuing onto the next index/element is more relevant I feel. --- jsonpath.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/jsonpath.go b/jsonpath.go index 00dc6fd..ff1ff46 100644 --- a/jsonpath.go +++ b/jsonpath.go @@ -465,7 +465,11 @@ func get_filtered(obj, root interface{}, filter string) ([]interface{}, error) { tmp := reflect.ValueOf(obj).Index(i).Interface() ok, err := eval_reg_filter(tmp, root, lp, pat) if err != nil { - return nil, err + if strings.ContainsAny(err.Error(), "key error: & not found in object") { + continue + } else { + return nil, err + } } if ok == true { res = append(res, tmp)