ds_protocol_http_py_lib.utils¶
Submodules¶
Functions¶
|
Recursively search for a set of keys in a nested JSON structure and return their value. |
Package Contents¶
- ds_protocol_http_py_lib.utils.find_keys_in_json(json_data: dict[str, Any] | list[Any], target_keys: set[str]) str | None[source]¶
Recursively search for a set of keys in a nested JSON structure and return their value.
- Parameters:
json_data – The JSON data to search through.
target_keys – A set of keys to search for.
- Returns:
The value of the found key as a string, or None if no key is found.
Example
>>> data = {"user": {"token": "abc123"}} >>> find_keys_in_json(data, {"token"}) 'abc123'