darcyai.output.json_output_stream
JSONOutputStream Objects
class JSONOutputStream(OutputStream)
OutputStream implementation that writes to a JSON file.
Arguments
- file_path (
str
): The path to the JSON file to write to. - buffer_size (
int
): The size of the buffer to use when writing to the JSON file. Defaults to0
. - flush_interval (
int
): The number of seconds before flushing the buffer to disk. Defaults to0
.
Examples
>>> from darcyai.output.json_output_stream import JSONOutputStream
>>> json_output_stream = JSONOutputStream(file_path="output.csv",
buffer_size=0)
write
def write(data: dict) -> None
Writes the given data to the JSON file.
Arguments
- data (
dict
): The data to write to the JSON file.
Examples
>>> from darcyai.output.json_output_stream import JSONOutputStream
>>> json_output_stream = JSONOutputStream(file_path="output.csv",
buffer_size=0)
>>> json_output_stream.write({"key": "value"})
close
def close() -> None
Closes the JSON file.
Examples
>>> from darcyai.output.json_output_stream import JSONOutputStream
>>> json_output_stream = JSONOutputStream(file_path="output.csv",
buffer_size=0)
>>> json_output_stream.close()