readObject

Reads an object and issues a callback for each field.

void
readObject
(
R
)
(
ref R nodes
,
scope void delegate
(
string key
)
@safe
del
)

Parameters

nodes R

An input range of JSON parser nodes

del void delegate
(
string key
)
@safe

The callback to invoke for each object field

Examples

auto j = parseJSONStream(q{
        {
            "foo": 1,
            "bar": 2
        }
    });

j.readObject((key) {
    auto value = j.readDouble;
    switch (key) {
        default: assert(false);
        case "foo": assert(value == 1); break;
        case "bar": assert(value == 2); break;
    }
});

assert(j.empty);

Meta