Writer for creating NDJSON (Newline Delimited JSON) output.
More...
#include <NdjsonWriter.qc.dox.h>
|
| void | constructor (Qore::OutputStream output_stream, soft< hash< NdjsonWriterOptions > > options) |
| | Creates the writer with an output stream.
|
| |
| int | write (auto value) |
| | Writes a JSON value as a line.
|
| |
| int | writeAll (list< auto > values) |
| | Writes multiple JSON values as lines.
|
| |
|
int | getRecordsWritten () |
| | Returns the number of records written.
|
| |
|
|
Qore::StreamWriter | writer |
| | The output stream.
|
| |
|
string | line_ending |
| | Line ending string.
|
| |
|
hash< NdjsonWriterOptions > | opts |
| | Writer options.
|
| |
Writer for creating NDJSON (Newline Delimited JSON) output.
This class provides methods for writing JSON values in NDJSON format to an output stream.
- Example
StringOutputStream sos();
NdjsonWriter writer(sos);
writer.write({"name": "Alice", "age": 30});
writer.write({"name": "Bob", "age": 25});
string result = sos.getData();
◆ constructor()
| void NdjsonDataProvider::NdjsonWriter::constructor |
( |
Qore::OutputStream |
output_stream, |
|
|
soft< hash< NdjsonWriterOptions > > |
options |
|
) |
| |
Creates the writer with an output stream.
- Parameters
-
| output_stream | the output stream to write to |
| options | writer options |
◆ write()
| int NdjsonDataProvider::NdjsonWriter::write |
( |
auto |
value | ) |
|
Writes a JSON value as a line.
- Parameters
-
| value | the value to serialize as JSON and write |
- Returns
- the number of bytes written
◆ writeAll()
| int NdjsonDataProvider::NdjsonWriter::writeAll |
( |
list< auto > |
values | ) |
|
Writes multiple JSON values as lines.
- Parameters
-
| values | the list of values to write |
- Returns
- the total number of bytes written
The documentation for this class was generated from the following file:
- doxygen/qlib/NdjsonDataProvider/NdjsonWriter.qc.dox.h