Working with optional attributes in JSON is quite inconvenient to write:
Stream stream = {
appId : js["appId"].str,
// like this
appVersion : js.object.get("appVersion", JSONValue("")).str,
// or that
startTimestamp : ("startTimestamp" in js is null) ? "" : js["startTimestamp"].str,
};
Adding opt* methods like optStr(string key, defaultValue = string.init) would make the usage a lot more readable:
Stream stream = {
appId : js["appId"].str,
appVersion : js.optStr("appVersion", "1.0"),
startTimestamp : js.optStr("startTimestamp")
};