Skip to content

JSON

Use libbot.utils.json to import the below functions.

Note

All functions are available in sync and async variants under the same name. Use await function_name() for async and function_name() for sync invocation.

json_read(path) async

Read contents of a JSON file and return it.

Parameters:

Name Type Description Default
path str | Path

Path-like object or path to the file as a string.

required

Returns:

Name Type Description
Any Any

File contents.

json_write(data, path) async

Write contents to a JSON file.

Parameters:

Name Type Description Default
data Any

Contents to write. Must be a JSON-serializable object.

required
path str | Path

Path-like object or path to the file as a string.

required