Function skipToKey

Skips all entries in an object until a certain key is reached.

bool skipToKey(R) (
  ref R nodes,
  string key
)
if (isJSONParserNodeInputRange!R);

The node range must either point to the start of an object (JSONParserNodeKind.objectStart), or to a key within an object (JSONParserNodeKind.key).

Parameters

NameDescription
nodes An input range of JSON parser nodes
key Name of the key to find

Returns

true is returned if and only if the specified key has been found.

Parameters

NameDescription
nodes An input range of JSON parser nodes

Example

auto j = parseJSONStream(q{
        {
            "foo": 2,
            "bar": 3,
            "baz": false,
            "qux": "str"
        }
    });

j.skipToKey("bar");
double v1 = j.readDouble;
assert(v1 == 3);

j.skipToKey("qux");
string v2 = j.readString;
assert(v2 == "str");

assert(j.front.kind == JSONParserNodeKind.objectEnd);
j.popFront();

assert(j.empty);