skipToKey

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

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

bool
skipToKey
(
R
)
(
ref R nodes
,
string key
)

Parameters

nodes R

An input range of JSON parser nodes

key string

Name of the key to find

Params:

nodes R

An input range of JSON parser nodes

Return Value

Type: bool

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

Examples

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

Meta