Comet.fromJson constructor
Implementation
Comet.fromJson(Map<String, dynamic> json) {
newOffset = json['new_offset'];
if (json['data'] != null) {
data = [];
List<dynamic>? dataList = json['data'];
if (dataList != null) {
dataList.forEach((element) {
Map<String, dynamic> cometData = element;
if (cometData['type'] != null) {
//Identify data type and deserialize them.
if (cometData['type'] == 'new_plurk') {
data!.add(CometNewPlurk.fromJson(cometData));
} else if (cometData['type'] == 'new_response') {
data!.add(CometNewResponse.fromJson(cometData));
} else if (cometData['type'] == 'update_notification') {
data!.add(CometUpdateNotification.fromJson(cometData));
} else {
//Un identified type.
print('Cannot identify comet data [' + cometData.toString() + ']');
}
}
});
}
}
}