toJson method
Implementation
@override
Map<String, dynamic> toJson() {
Map<String, dynamic> jsonObject = {};
jsonObject['id'] = id;
if (alsoKnownAs != null) jsonObject['alsoKnownAs'] = alsoKnownAs;
if (controller != null) jsonObject['controller'] = controller;
if (verificationMethod != null && verificationMethod!.isNotEmpty) {
List tmp = [];
for (var v in verificationMethod!) {
tmp.add(v.toJson());
}
jsonObject['verificationMethod'] = tmp;
}
if (authentication != null && authentication!.isNotEmpty) {
List tmp = [];
for (var v in authentication!) {
if (v is VerificationMethod) {
tmp.add(v.toJson());
} else if (v is String) {
tmp.add(v);
} else {
throw FormatException('unknown Datatype');
}
}
jsonObject['authentication'] = tmp;
}
if (capabilityDelegation != null && capabilityDelegation!.isNotEmpty) {
List tmp = [];
for (var v in capabilityDelegation!) {
if (v is VerificationMethod) {
tmp.add(v.toJson());
} else if (v is String) {
tmp.add(v);
} else {
throw FormatException('unknown Datatype');
}
}
jsonObject['capabilityDelegation'] = tmp;
}
if (capabilityInvocation != null && capabilityInvocation!.isNotEmpty) {
List tmp = [];
for (var v in capabilityInvocation!) {
if (v is VerificationMethod) {
tmp.add(v.toJson());
} else if (v is String) {
tmp.add(v);
} else {
throw FormatException('unknown Datatype');
}
}
jsonObject['capabilityInvocation'] = tmp;
}
if (keyAgreement != null && keyAgreement!.isNotEmpty) {
List tmp = [];
for (var v in keyAgreement!) {
if (v is VerificationMethod) {
tmp.add(v.toJson());
} else if (v is String) {
tmp.add(v);
} else {
throw FormatException('unknown Datatype');
}
}
jsonObject['keyAgreement'] = tmp;
}
if (assertionMethod != null && assertionMethod!.isNotEmpty) {
List tmp = [];
for (var v in assertionMethod!) {
if (v is VerificationMethod) {
tmp.add(v.toJson());
} else if (v is String) {
tmp.add(v);
} else {
throw FormatException('unknown Datatype');
}
}
jsonObject['assertionMethod'] = tmp;
}
if (service != null && service!.isNotEmpty) {
List tmp = [];
for (var v in service!) {
tmp.add(v.toJson());
}
jsonObject['verificationMethod'] = tmp;
}
return jsonObject;
}