VerifiablePresentation.fromJson constructor
VerifiablePresentation.fromJson(
- dynamic jsonObject
Implementation
VerifiablePresentation.fromJson(dynamic jsonObject) {
var presentation = credentialToMap(jsonObject);
if (presentation.containsKey('@context')) {
context = presentation['@context'].cast<String>();
} else {
throw FormatException(
'context property is needed in verifiable presentation');
}
if (presentation.containsKey('type')) {
type = presentation['type'].cast<String>();
} else {
throw FormatException(
'type property is needed in verifiable presentation');
}
if (presentation.containsKey('verifiableCredential')) {
verifiableCredential = [];
List tmp = presentation['verifiableCredential'];
for (var c in tmp) {
verifiableCredential!.add(VerifiableCredential.fromJson(c));
}
}
id = presentation['id'];
holder = presentation['holder'];
if (presentation.containsKey('proof')) {
proof = [];
var tmp = presentation['proof'];
if (tmp is List) {
for (var c in tmp) {
proof!.add(LinkedDataProof.fromJson(c));
}
} else if (tmp is Map) {
proof!.add(LinkedDataProof.fromJson(tmp));
}
}
if (presentation.containsKey('presentation_submission')) {
var tmp = presentation['presentation_submission'];
presentationSubmission = PresentationSubmission.fromJson(tmp);
}
if (presentation.containsKey('credential_fulfillment')) {
credentialFulfillment = CredentialFulfillment.fromJson(
presentation['credential_fulfillment']);
}
if (presentation.containsKey('credential_application')) {
credentialApplication = CredentialApplication.fromJson(
presentation['credential_application']);
}
_originalDoc = presentation;
}