Asdf.get

struct Asdf
T
get
(
T
)
(
T def
)

Parameters

def T

default value. It is used when ASDF value equals Asdf.init.

Return Value

Type: T

cast(T) this if this != Asdf.init and def otherwise.

Examples

import asdf.jsonparser;
auto asdfData = `{"foo":"bar","inner":{"a":true,"b":false,"c":"32323","d":null,"e":{}}}`.parseJson;
assert(asdfData["inner", "a"].get(false) == true);
assert(asdfData["inner", "b"].get(true) == false);
assert(asdfData["inner", "c"].get(100) == 32323);
assert(asdfData["no", "such", "keys"].get(100) == 100);

Meta