Function readObject

Reads an object and issues a callback for each field.

void readObject(R) (
  ref R nodes,
  scope @safe void delegate(string key) del
)
if (isJSONParserNodeInputRange!R);

Parameters

NameDescription
nodes An input range of JSON parser nodes
del The callback to invoke for each object field

Example

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);