save_json()

audeer.save_json(file, obj, *, indent=None, separators=None)[source]

Save object to JSON file.

Parameters:
  • file (str | bytes) – path to JSON file

  • obj (object) – object to store in JSON file

  • indent (int | None) – indentation level in number of spaces. If None the JSON will be compact without line breaks

  • separators (tuple[str, str] | None) – tuple of item and key separators. If None defaults to (", ", ": ") when indent is None, and (",", ": ") otherwise

Examples

>>> file = audeer.path("test.json")
>>> audeer.save_json(file, {"a": 1})
>>> audeer.load_json(file)
{'a': 1}