From 98221626d3617543ec35ee7526b3c8eb900a2c49 Mon Sep 17 00:00:00 2001 From: TwinProduction Date: Fri, 24 Jul 2020 13:20:28 -0400 Subject: [PATCH] Fix issue with json path when expected path doesn't match actual path --- jsonpath/jsonpath.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/jsonpath/jsonpath.go b/jsonpath/jsonpath.go index 302c9104..3dc400b3 100644 --- a/jsonpath/jsonpath.go +++ b/jsonpath/jsonpath.go @@ -52,6 +52,9 @@ func extractValue(currentKey string, value interface{}) interface{} { } return nil } + if value == nil || value.(map[string]interface{})[currentKey] == nil { + return nil + } // if currentKey contains both a key and an index (i.e. data[0]) array := value.(map[string]interface{})[currentKey].([]interface{}) if len(array) > arrayIndex {