Fghj.get

struct Fghj
T
get
(
T
)
(
T def
)

Parameters

def T

default value. It is used when FGHJ value equals Fghj.init.

Return Value

Type: T

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

Examples

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

Meta