toJson method

  1. @override
Map<String, dynamic> toJson()
override

Serializes the JsonWebSignature or JsonWebEncryption to a JSON representation.

For JsonWebSignature, returns a flattened JSON serialization when it contains only one signature and a general JSON serialization otherwise.

Implementation

@override
Map<String, dynamic> toJson() {
  var v = <String, dynamic>{'payload': encodeBase64EncodedBytes(data)};
  if (recipients.length == 1) {
    v.addAll(recipients.first.toJson());
  } else {
    v['signatures'] = recipients.map((v) => v.toJson()).toList();
  }
  return v;
}