pythonwrench.json module¶
-
pythonwrench.json.dump_json(data: Any, file: str | Path | None | TextIOBase =
None, /, *, overwrite: bool =True, make_parents: bool =True, to_builtins: bool =False, indent: int | None =4, ensure_ascii: bool =False, **json_dumps_kwds) str[source]¶ Dump content to JSON format into a string and/or file.
- Args:
data: Data to dump to JSON. file: Optional filepath to save dumped data. Not used if None. defaults to None. overwrite: If True, overwrite target filepath. defaults to True. make_parents: Build intermediate directories to filepath. defaults to True. to_builtins: If True, converts data to builtin equivalent before saving. defaults to False. indent: JSON indentation size in spaces. defaults to 4. ensure_ascii: Ensure only ASCII characters. defaults to False. **json_dump_kwds: Other args passed to json.dumps.
- Returns:
Dumped content as string.
-
pythonwrench.json.dumps_json(data: Any, /, *, to_builtins: bool =
False, indent: int | None =4, ensure_ascii: bool =False, **json_dumps_kwds) str[source]¶
- pythonwrench.json.load_json(file: str | Path | PathLike | TextIOBase, /, **json_loads_kwds) Any[source]¶
- pythonwrench.json.read_json(file: str | Path | PathLike | TextIOBase, /, **json_loads_kwds) Any[source]¶
-
pythonwrench.json.save_json(data: Any, file: str | Path | PathLike | TextIOBase, /, *, overwrite: bool =
True, make_parents: bool =True, to_builtins: bool =False, indent: int | None =4, ensure_ascii: bool =False, **json_dumps_kwds) None[source]¶