Skip to content

Commit 9822162

Browse files
committed
Fix issue with json path when expected path doesn't match actual path
1 parent 60e30da commit 9822162

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

jsonpath/jsonpath.go

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,9 @@ func extractValue(currentKey string, value interface{}) interface{} {
5252
}
5353
return nil
5454
}
55+
if value == nil || value.(map[string]interface{})[currentKey] == nil {
56+
return nil
57+
}
5558
// if currentKey contains both a key and an index (i.e. data[0])
5659
array := value.(map[string]interface{})[currentKey].([]interface{})
5760
if len(array) > arrayIndex {

0 commit comments

Comments
 (0)