jsonned ~master
A binding to jsonnet for Dlang
To use this package, run the following command in your project's root directory:
Manual usage
Put the following dependency into your project's dependences section:
jsonneD: Binding to jsonnet for the D Programming language
///
unittest {
import std.json;
JsonneD jn = JsonneD();
string s = `
{
person1: {
name: "Alice",
welcome: "Hello " + self.name + "!",
},
person2: self.person1 {
name: std.extVar("OTHER_NAME"),
},
}`;
jn.extVar("OTHER_NAME", "Robert Schadek");
auto eval = jn.evaluateSnippet("foo.json", s);
JSONValue exp = parseJSON(`
{
"person1": {
"name": "Alice",
"welcome": "Hello Alice!"
},
"person2": {
"name": "Robert Schadek",
"welcome" : "Hello Robert Schadek!"
}
}`);
assert(!eval.rslt.isNull);
JSONValue r = parseJSON(eval.rslt.get());
assert(exp == r, format("\nexp:\n%s\neva:\n%s", exp.toPrettyString(),
r.toPrettyString()));
}
///
unittest {
import std.json;
JsonneD jn = JsonneD();
auto rs = jn.evaluteFileMulti("tests/m0.jsonnnet");
assert(rs.length == 2, format("%s", rs.length));
assert(rs[0].filename == "a.json");
assert(rs[1].filename == "b.json");
}
///
unittest {
import std.json;
string s = `
{
"a.json": {
x: 1,
y: $["b.json"].y,
},
"b.json": {
x: $["a.json"].x,
y: 2,
},
}
`;
JsonneD jn = JsonneD();
auto rs = jn.evaluteSnippetMulti("foo.json", s);
assert(rs.length == 2, format("%s", rs.length));
assert(rs[0].filename == "a.json");
assert(rs[1].filename == "b.json");
}
Documentation
The Documentation is still WIP, please have a look at the vibe.d project in the test folder.
Contributing
PRs are welcome!
- ~master released 2 months ago
- symmetryinvestments/jsonneD
- LGPL3
- Copyright © 2019, Symmetry Investments
- Authors:
- Dependencies:
- none
- Versions:
-
1.0.3 2019-Oct-11 1.0.2 2019-Oct-11 1.0.1 2019-Oct-11 1.0.0 2019-Oct-03 ~master 2024-Oct-28 - Download Stats:
-
-
0 downloads today
-
0 downloads this week
-
0 downloads this month
-
19 downloads total
-
- Score:
- 1.4
- Short URL:
- jsonned.dub.pm