Initial AP objects implementation

This commit is contained in:
2024-02-21 11:07:26 -03:00
parent a0b15f6526
commit f9dedca988
5 changed files with 167 additions and 1 deletions

20
source/util.d Normal file
View File

@@ -0,0 +1,20 @@
module util;
import std.format;
import std.json;
JSONValue requiredKey(string key)(JSONValue val) {
const(JSONValue)* j = key in val;
if (j)
return *j;
throw new Exception(format("Key %s not found in json", key));
}
T checkKey(T)(JSONValue val, string key) {
if (JSONValue* j = key in val)
return (*j).get!T;
return T.init;
}