readArray

Reads an array and issues a callback for each entry.

void
readArray
(
R
)
(
ref R nodes
,
scope void delegate
()
@safe
del
)

Parameters

nodes R

An input range of JSON parser nodes

del void delegate
()
@safe

The callback to invoke for each array entry

Examples

auto j = parseJSONStream(q{
        [
            "foo",
            "bar"
        ]
    });

size_t i = 0;
j.readArray({
    auto value = j.readString();
    switch (i++) {
        default: assert(false);
        case 0: assert(value == "foo"); break;
        case 1: assert(value == "bar"); break;
    }
});

assert(j.empty);

Meta