Skip to main content

dump

Serialize data as JSON and write to a file.

def dump(
obj: Any,
fp: IO[str],
kwargs: Any
) - > None

Serialize data as JSON and write to a file. If flask.current_app is available, it will use its app.json.dump() method, otherwise it will use json.dump.

Parameters

NameTypeDescription
objAnyThe data object to be serialized into JSON format.
fpIO[str]A file-like object opened for writing text, which should use UTF-8 encoding to ensure valid JSON output.
kwargsAnyAdditional keyword arguments passed to the underlying JSON dump implementation.

Returns

TypeDescription
NoneNothing is returned; the output is written directly to the file pointer.