CredentialManifest.fromJson constructor

CredentialManifest.fromJson(
  1. dynamic jsonObject
)

Implementation

CredentialManifest.fromJson(dynamic jsonObject) {
  var map = credentialToMap(jsonObject);
  if (map.containsKey('id')) {
    id = map['id'];
  } else {
    throw Exception('id property needed in Credential manifest');
  }
  name = map['name'];
  description = map['description'];
  specVersion = map['spec_version'] ??
      'https://identity.foundation/credential-manifest/spec/v0.0.0/';
  if (map.containsKey('issuer')) {
    issuer = IssuerProperty.fromJson(map['issuer']);
  } else {
    throw Exception('issuer property needed');
  }
  if (map.containsKey('output_descriptors')) {
    var descriptorList = map['output_descriptors'];
    outputDescriptor = [];
    for (var d in descriptorList) {
      outputDescriptor.add(OutputDescriptor.fromJson(d));
    }
  } else {
    throw Exception('output_descriptors needed in credential Manifest');
  }
  if (map.containsKey('format')) {
    format = FormatProperty.fromJson(map['format']);
  }
  if (map.containsKey('presentation_definition')) {
    presentationDefinition =
        PresentationDefinition.fromJson(map['presentation_definition']);
  }
}