Better json management
This commit is contained in:
@@ -33,19 +33,16 @@ class Actor : ASObject {
|
||||
super(json);
|
||||
|
||||
with (this) {
|
||||
inbox = json.requiredKey!"inbox".str;
|
||||
outbox = json.requiredKey!"outbox".str;
|
||||
following = json.requiredKey!"following".str;
|
||||
followers = json.requiredKey!"followers".str;
|
||||
required(json, "inbox", inbox);
|
||||
required(json, "outbox", outbox);
|
||||
required(json, "following", following);
|
||||
required(json, "followers", followers);
|
||||
|
||||
liked = json.checkKey!string("liked");
|
||||
streams = json.checkKey!string("streams");
|
||||
preferredUsername = json.checkKey!string("preferredUsername");
|
||||
optional(json, "liked", liked);
|
||||
optional(json, "streams", streams);
|
||||
optional(json, "preferredUsername", preferredUsername);
|
||||
|
||||
if (JSONValue* j = "endpoints" in json)
|
||||
endpoints = ActorEndpoints.fromJson(*j);
|
||||
else
|
||||
endpoints = ActorEndpoints();
|
||||
endpoints = ActorEndpoints.fromJson(json.optional!JSONValue("endpoints"));
|
||||
|
||||
raw = json;
|
||||
}
|
||||
@@ -64,12 +61,12 @@ struct ActorEndpoints {
|
||||
ActorEndpoints endpoints = ActorEndpoints();
|
||||
|
||||
with (endpoints) {
|
||||
proxyUrl = json.checkKey!string("proxyUrl");
|
||||
oauthAuthorizationEndpoint = json.checkKey!string("oauthAuthorizationEndpoint");
|
||||
oauthTokenEndpoint = json.checkKey!string("oauthTokenEndpoint");
|
||||
provideClientKey = json.checkKey!string("provideClientKey");
|
||||
signClientKey = json.checkKey!string("signClientKey");
|
||||
sharedInbox = json.checkKey!string("sharedInbox");
|
||||
optional(json, "proxyUrl", proxyUrl);
|
||||
optional(json, "oauthAuthorizationEndpoint", oauthAuthorizationEndpoint);
|
||||
optional(json, "oauthTokenEndpoint", oauthTokenEndpoint);
|
||||
optional(json, "provideClientKey", provideClientKey);
|
||||
optional(json, "signClientKey", signClientKey);
|
||||
optional(json, "sharedInbox", sharedInbox);
|
||||
}
|
||||
|
||||
return endpoints;
|
||||
|
||||
Reference in New Issue
Block a user