Vibe.d Json API
Theese are some utilities that helps you to write easier asserts for the Json data type provided by the vibe.d library.
Setup
- Include the vibe assert package package:
fluent-asserts-vibe
- Import the module:
import fluentasserts.vibe.json
orimport fluent.asserts
Summary
Examples
Keys
string[] keys(Json obj, const string file = __FILE__, const size_t line = __LINE__)
Returns an array that contains the keys of an Json object.
Success expectations
Json.emptyObject.keys.length.should.equal(0);
auto obj = Json.emptyObject;
obj["key1"] = 1;
obj["key2"] = 3;
obj.keys.length.should.equal(2);
obj.keys.should.contain(["key1", "key2"]);
Failing expectations
Json.emptyArray.keys.should.contain(["key1", "key2"]);
// fails with: The json should be an object. `array` found.