preprocess

preprocess

Examples

    import dyaml : Loader;
    import std.path : absolutePath;

    auto context = LoadingContext(
        "file://"~"examples/import/parent.json".absolutePath,
    );

    enum str = q"EOS
        "bar": {
            "$import": "import.json"
        }
EOS";

    auto node = Loader.fromString(str).load;
    auto processed = node["bar"].preprocess(context);
    assert("hello" in processed);
    assert(processed["hello"] == "world");
    import dyaml : Loader;
    import std.path : absolutePath;

    auto context = LoadingContext(
        "file://"~"examples/include/parent.json".absolutePath,
    );

    enum str = q"EOS
        "bar": {
            "$include": "include.txt"
        }
EOS";

    auto node = Loader.fromString(str).load;
    auto processed = node["bar"].preprocess(context);
    assert(processed == "hello world");

See Also

Meta