Qore json Module 1.11.0
Loading...
Searching...
No Matches
NdjsonDataProvider::NdjsonIterator Class Reference

Iterator for reading NDJSON (Newline Delimited JSON) data from a string. More...

#include <NdjsonIterator.qc.dox.h>

Inherits AbstractIterator.

Public Member Methods

auto getValue ()
 Returns the current JSON value.
 
bool valid ()
 Returns True if the iterator is valid.
 
int getLineNumber ()
 Returns the current line number (1-based)
 
void reset ()
 Resets the iterator to the beginning.
 

Private Attributes

list< string > lines
 The list of lines to iterate over.
 
auto current_value
 Current parsed value.
 
hash< NdjsonIteratorOptionsopts
 Options for the iterator.
 

Detailed Description

Iterator for reading NDJSON (Newline Delimited JSON) data from a string.

This class provides an iterator interface for reading NDJSON formatted data. Each call to next() advances to the next JSON line, and getValue() returns the parsed JSON value.

Example
string ndjson = '{"id": 1}\n{"id": 2}\n{"id": 3}';
NdjsonIterator iter(ndjson);
while (iter.next()) {
printf("Value: %y\n", iter.getValue());
}

Member Function Documentation

◆ getValue()

auto NdjsonDataProvider::NdjsonIterator::getValue ( )

Returns the current JSON value.

Returns
the parsed JSON value
Exceptions
ITERATOR-ERRORif the iterator is not valid

The documentation for this class was generated from the following file: