bgdev.utils.serialize¶
Utility methods for data serialization (JSON, YAML, PKL, etc…).
- created
26/04/2018
- author
Benoit Gielly <benoit.gielly@gmail.com>
-
json_dump
(data, path, **kwargs)[source]¶ Export JSON file.
- Parameters
data (dict) – Dictionary to export as JSON
path (str) – JSON file path to save data
kwargs (dict) – Any extra flags to pass in the
json.dump()
command
- Returns
given file path
- Return type
str
-
json_load
(path, **kwargs)[source]¶ Import JSON file.
- Parameters
path (str) – JSON file path to save data
kwargs (dict) – Any extra flags to pass in the
json.load()
command
- Returns
The loaded data.
- Return type
dict
-
yaml_dump
(data, path, ordered=False, **kwargs)[source]¶ Export YAML file.
- Parameters
data (dict) – Dictionary to export as JSON
path (str) – YAML file path to save data
ordered (bool) – Dump data ordered when True.
kwargs (dict) – Any extra flags to pass in the
json.dump()
command
- Returns
given file path
- Return type
str