A JSON Lines (https://jsonlines.org) implementation with iterator support. Every non-empty line in a JSONL stream is a complete, valid JSON value, and lines are separated by newline characters (U+000A). Multi-line JSON values are not supported, as per the JSONL specification. Blank and whitespace-only lines are skipped rather than treated as errors. JSON Lines is a convention rather than a formal specification, so tolerating stray blank lines is friendlier to real-world input. More...
Classes | |
| class | sourcemeta::core::JSONL |
| class | sourcemeta::core::ConstJSONLIterator |
A JSON Lines (https://jsonlines.org) implementation with iterator support. Every non-empty line in a JSONL stream is a complete, valid JSON value, and lines are separated by newline characters (U+000A). Multi-line JSON values are not supported, as per the JSONL specification. Blank and whitespace-only lines are skipped rather than treated as errors. JSON Lines is a convention rather than a formal specification, so tolerating stray blank lines is friendlier to real-world input.
This functionality is included as follows:
| class sourcemeta::core::JSONL |
Public Types | |
| enum class | Mode : std::uint8_t { Raw , GZIP } |
| The mode of operation for the JSONL parser. More... | |
Public Member Functions | |
| JSONL (std::basic_istream< JSON::Char, JSON::CharTraits > &stream, Mode mode=Mode::Raw) | |
| JSONL (const JSONL &)=delete | |
| JSONL (JSONL &&)=delete | |
|
strong |
| sourcemeta::core::JSONL::JSONL | ( | std::basic_istream< JSON::Char, JSON::CharTraits > & | stream, |
| Mode | mode = Mode::Raw ) |
Parse a JSONL document from a C++ standard input stream using a standard read-only C++ forward iterator interface. An optional mode parameter controls whether the input is treated as raw text or gzip-compressed data. For example, you can parse a JSONL document and prettify each of its rows as follows:
If parsing fails, sourcemeta::core::JSONParseError will be thrown.
| class sourcemeta::core::ConstJSONLIterator |
A forward iterator to parse JSON documents out of a JSON Lines stream. Blank and whitespace-only lines are skipped rather than treated as errors, as JSON Lines is a convention rather than a formal specification and tolerating stray blank lines is friendlier to real-world input.
Public Member Functions | |
| ConstJSONLIterator (std::basic_istream< JSON::Char, JSON::CharTraits > *stream) | |
| Construct an iterator over the JSON documents in a stream. | |