serializefilters
Class info¶
🛈 DocStrings¶
deserialize
¶
Serialize given json-like object to given format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
str
|
The data to deserialize |
required |
fmt
|
SerializeFormatStr
|
The serialization format |
required |
kwargs
|
Any
|
Keyword arguments passed to the loader function |
{}
|
Source code in src/jinjarope/serializefilters.py
dig
¶
dig(
data: dict[str, Any] | list[Any] | str,
*sections: str,
keep_path: bool = False,
dig_yaml_lists: bool = True
) -> Any
Try to get data with given section path from a dict-list structure.
If a list is encountered and dig_yaml_lists is true, treat it like a list of {"identifier", {subdict}} items, as used in MkDocs config for plugins & extensions. If Key path does not exist, return None.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any] | list[Any] | str
|
The data to dig into |
required |
sections
|
str
|
Sections to dig into |
()
|
keep_path
|
bool
|
Return result with original nesting |
False
|
dig_yaml_lists
|
bool
|
Also dig into single-key->value pairs, as often found in yaml. |
True
|
Source code in src/jinjarope/serializefilters.py
merge
¶
merge(
target: list[Any] | dict[str, Any],
*source: list[Any] | dict[str, Any],
deepcopy: bool = False,
mergers: dict[type, Callable[[Any, Any, Any], Any]] | None = None
) -> list[Any] | dict[str, Any]
Merge given data structures using mergers provided.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
target
|
list[Any] | dict[str, Any]
|
Data structure to merge into |
required |
source
|
list[Any] | dict[str, Any]
|
Data structures to merge into target |
()
|
deepcopy
|
bool
|
Whether to deepcopy the target |
False
|
mergers
|
dict[type, Callable[[Any, Any, Any], Any]] | None
|
Mergers with strategies for each type (default: additive) |
None
|
Source code in src/jinjarope/serializefilters.py
serialize
¶
Serialize given json-like object to given format.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Any
|
The data to serialize |
required |
fmt
|
SerializeFormatStr
|
The serialization format |
required |
kwargs
|
Any
|
Keyword arguments passed to the dumper function |
{}
|