write_json

write_json(file, data, writer=None, mode='w+', encoder=None, **opts): 

LLM Docstring

Serialize data to a file as JSON, separating open options from dumper options and supporting a custom encoder class or default function.

  • file: Any

    the file path or stream

  • data: Any

    the data to serialize

  • writer: Callable | None

    the JSON writer (defaults to json.dump)

  • mode: str

    the open mode

  • encoder: Any

    a JSON encoder class or default-serializer function

  • opts: Any

    mixed open and dumper options

  • :returns: _

    the writer’s result


Feedback

Examples

Templates

Documentation