SubscriptionsResponse.fromJson constructor
Parses a SubscriptionsResponse from a JSON-LD map.
Implementation
factory SubscriptionsResponse.fromJson(Map<String, dynamic> json) {
try {
final subs = (json['subscriptions'] as List<dynamic>)
.cast<Map<String, dynamic>>()
.map(SubscriptionInfo.fromJson)
.toList(growable: false);
return SubscriptionsResponse(
context: json['@context'] as String,
id: json['id'] as String,
type: json['type'] as String,
lastEventId: json['lastEventID'] as String,
subscriptions: subs,
);
} on TypeError catch (e) {
throw FormatException(
'Invalid subscriptions response JSON: $e',
json.toString(),
);
}
}