Campaigns.fromJson constructor
Campaigns.fromJson(
- Map<String, dynamic> json
)
Implementation
Campaigns.fromJson(Map<String, dynamic> json) {
// Set visitorId
visitorId = (json['visitorId'] ?? "") as String;
// Set panic
if (json.keys.contains("panic")) {
panic = json['panic'] as bool;
}
var list = (json['campaigns'] ?? []) as List<dynamic>;
campaigns = list.map((e) {
return Campaign.fromJson(e);
}).toList();
// Init AccountSettings
try {
if (json['extras']['accountSettings'] != null) {
accountSettings =
AccountSettings.fromJson(json['extras']['accountSettings'] ?? {});
}
} catch (e) {
// In panic mode the extras field in not present
}
}