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

Function json_decode

st2common/st2common/util/jsonify.py:121–136  ·  view source on GitHub ↗

Wrapper function for decoding the provided JSON string. This function automatically select appropriate JSON library based on the configuration value. This function should be used everywhere in the code base where json.loads() behavior is desired.

(data)

Source from the content-addressed store, hash-verified

119
120
121def json_decode(data):
122 """
123 Wrapper function for decoding the provided JSON string.
124
125 This function automatically select appropriate JSON library based on the configuration value.
126
127 This function should be used everywhere in the code base where json.loads() behavior is desired.
128 """
129 json_library = DEFAULT_JSON_LIBRARY
130
131 if json_library == "json":
132 return json_decode_native_json(data=data)
133 elif json_library == "orjson":
134 return json_decode_orjson(data=data)
135 else:
136 raise ValueError("Unsupported json_library: %s" % (json_library))
137
138
139def load_file(path):

Callers 13

_get_output_valuesMethod · 0.90
_cast_objectMethod · 0.90
get_allMethod · 0.90
_json_body__getMethod · 0.90
_json_body__getMethod · 0.90
to_serializable_dictMethod · 0.90
_renderFunction · 0.90
_cast_objectFunction · 0.90
read_crypto_keyFunction · 0.90
render_valuesFunction · 0.90
json_loadsFunction · 0.85

Calls 2

json_decode_native_jsonFunction · 0.85
json_decode_orjsonFunction · 0.85

Tested by

no test coverage detected