json_tree.JSONTree¶
- class xbrl_filings_api.json_tree.JSONTree¶
Bases:
objectObject for traversing and parsing API response.
When the required keys have been read, method
close()must be called in the init methods ofAPIObjectsubclasses. This ensures the keys which were never accessed (novel API features) are available via the two class methods.The class methods
get_unaccessed_key_paths()andget_key_path_availability_counts()are preferred to be called via the identically named functions of thedebugmodule.Methods
close()Close JSON tree for reading.
get(key_path[, parse_type])Read JSON data from dict and parse values to Python literals.
Get counts of dot access paths not resolving to
None.Get unaccessed dot access paths of JSON objects.
__hash__()Return hash(self).
__repr__()Return repr(self).
__str__()Return str(self).
Attributes
Set of unexpected API resource types.
The
__qualname__of the ownerAPIObjectsubclass.JSON fragment as Python dict from API page response.
Base URL for ParseType.URL.
When
True, does not track successful and totalget()method calls fordebugmodule.- unexpected_resource_types: ClassVar[set[tuple[str, str]]] = {}¶
Set of unexpected API resource types.
Read by calling function
debug.get_unexpected_resource_types.Content:
unexpected_resource_types.pop() = (type_str, origin)
- classmethod get_key_path_availability_counts()¶
Get counts of dot access paths not resolving to
None.See documentation of
debug.get_key_path_availability_counts().- Return type:
set[KeyPathRetrieveCounts]
- classmethod get_unaccessed_key_paths()¶
Get unaccessed dot access paths of JSON objects.
See documentation of
debug.get_unaccessed_key_paths().
- tree: dict[str, Any] | None¶
JSON fragment as Python dict from API page response.
An
APIPagesubclass contains the whole JSON document.
- do_not_track: bool¶
When
True, does not track successful and totalget()method calls fordebugmodule.
- close()¶
Close JSON tree for reading.
Remember all unaccessed and never existing dot access paths in the nested dictionary structure but skip lists.
- Return type:
None
- get(key_path, parse_type=None)¶
Read JSON data from dict and parse values to Python literals.
Value
ParseType.DATETIMEof parameterparse_typeparses ISO style UTC strings such as'2023-05-09 10:51:50.382633'. The return value is locale-aware and if the string does not specify timezone, it will be on UTC.Value
ParseType.DATEparses naive dates andParseType.URLresolves relative URLs based onrequest_url.