save_json

save_json(location: str, key: str, obj: dict | list, levels: int = 5) None[source]

Save dict or list as json to key at specified location.

Method will save to the S3 bucket if the location begins with the s3:// protocol, otherwise it assumes the location is a local path.

The json is pretty printed with an indentation level of 2. For lists, default pretty printing places each item on a new line which can produce very long files. This method will attempt map lists up to the specified number of items onto a single line.

Parameters:
  • location – Object location (local path or S3 bucket).

  • key – Object key ending in .json.

  • obj – Dict or list to save.

  • levels – Maximum number of items for single line list.