Given I have the following TypeScript class
<code>export class OidcConfig {
displayName: string;
issuer: string;
clientId: string = "app";
sessionChecksEnabled: boolean = false;
}
</code>
<code>export class OidcConfig {
displayName: string;
issuer: string;
clientId: string = "app";
sessionChecksEnabled: boolean = false;
}
</code>
export class OidcConfig {
displayName: string;
issuer: string;
clientId: string = "app";
sessionChecksEnabled: boolean = false;
}
Is it possible to bind the following JSON to an object of the class above, similarily how it can be bound to an interface, retaining the default values (clientId
, sessionChecksEnabled
) when not given in JSON?
<code>{
"displayName": "Keycloak",
"issuer": "https://sso.example.com/realms/my-realm"
}
</code>
<code>{
"displayName": "Keycloak",
"issuer": "https://sso.example.com/realms/my-realm"
}
</code>
{
"displayName": "Keycloak",
"issuer": "https://sso.example.com/realms/my-realm"
}
I am using Angular (13).
I tried looking around, but primarily found solutions involving interfaces (i.e. no default values), and not dealing with default values.
I tried to simply using a class instead of an interface, but it does not retain default values. If necessary I will try to build a MRE.