MCPcopy Create free account
hub / github.com/StackStorm/st2 / _get_value_complex

Function _get_value_complex

st2client/st2client/utils/jsutil.py:64–77  ·  view source on GitHub ↗

Extracts a value from a nested set of dictionaries 'doc' based on a 'key' string. The key is expected to be a jsonpath_rw expression: http://jsonpath-rw.readthedocs.io/en/stable/ Returns the extracted value from the key specified (if found) Returns None if the key can not b

(doc, key)

Source from the content-addressed store, hash-verified

62
63
64def _get_value_complex(doc, key):
65 """
66 Extracts a value from a nested set of dictionaries 'doc' based on
67 a 'key' string.
68 The key is expected to be a jsonpath_rw expression:
69 http://jsonpath-rw.readthedocs.io/en/stable/
70
71 Returns the extracted value from the key specified (if found)
72 Returns None if the key can not be found
73 """
74 jsonpath_expr = parse(key)
75 matches = jsonpath_expr.find(doc)
76 value = None if len(matches) < 1 else matches[0].value
77 return value
78
79
80def get_value(doc, key):

Callers 1

get_valueFunction · 0.85

Calls 1

parseFunction · 0.70

Tested by

no test coverage detected