import 'dart:convert'; DnsStatistics dnsStatisticsFromJson(String str) => DnsStatistics.fromJson(json.decode(str)); String dnsStatisticsToJson(DnsStatistics data) => json.encode(data.toJson()); class DnsStatistics { final String timeUnits; final List> topQueriedDomains; final List> topClients; final List> topBlockedDomains; final List>? topUpstreamResponses; final List>? topUpstreamsAvgTime; final List dnsQueries; final List blockedFiltering; final List replacedSafebrowsing; final List replacedParental; final int numDnsQueries; final int numBlockedFiltering; final int numReplacedSafebrowsing; final int numReplacedSafesearch; final int numReplacedParental; final double avgProcessingTime; DnsStatistics({ required this.timeUnits, required this.topQueriedDomains, required this.topClients, required this.topBlockedDomains, required this.topUpstreamResponses, required this.topUpstreamsAvgTime, required this.dnsQueries, required this.blockedFiltering, required this.replacedSafebrowsing, required this.replacedParental, required this.numDnsQueries, required this.numBlockedFiltering, required this.numReplacedSafebrowsing, required this.numReplacedSafesearch, required this.numReplacedParental, required this.avgProcessingTime, }); factory DnsStatistics.fromJson(Map json) => DnsStatistics( timeUnits: json["time_units"], topQueriedDomains: List>.from(json["top_queried_domains"].map((x) => Map.from(x).map((k, v) => MapEntry(k, v)))), topClients: List>.from(json["top_clients"].map((x) => Map.from(x).map((k, v) => MapEntry(k, v)))), topBlockedDomains: List>.from(json["top_blocked_domains"].map((x) => Map.from(x).map((k, v) => MapEntry(k, v)))), topUpstreamResponses: json["top_upstreams_responses"] != null ? List>.from(json["top_upstreams_responses"].map((x) => Map.from(x).map((k, v) => MapEntry(k, v)))) : null, topUpstreamsAvgTime: json["top_upstreams_avg_time"] != null ? List>.from(json["top_upstreams_avg_time"].map((x) => Map.from(x).map((k, v) => MapEntry(k, v)))) : null, dnsQueries: List.from(json["dns_queries"].map((x) => x)), blockedFiltering: List.from(json["blocked_filtering"].map((x) => x)), replacedSafebrowsing: List.from(json["replaced_safebrowsing"].map((x) => x)), replacedParental: List.from(json["replaced_parental"].map((x) => x)), numDnsQueries: json["num_dns_queries"], numBlockedFiltering: json["num_blocked_filtering"], numReplacedSafebrowsing: json["num_replaced_safebrowsing"], numReplacedSafesearch: json["num_replaced_safesearch"], numReplacedParental: json["num_replaced_parental"], avgProcessingTime: json["avg_processing_time"].toDouble(), ); Map toJson() => { "time_units": timeUnits, "top_queried_domains": List.from(topQueriedDomains.map((x) => Map.from(x).map((k, v) => MapEntry(k, v)))), "top_clients": List.from(topClients.map((x) => Map.from(x).map((k, v) => MapEntry(k, v)))), "top_blocked_domains": List.from(topBlockedDomains.map((x) => Map.from(x).map((k, v) => MapEntry(k, v)))), "top_upstreams_responses": topUpstreamResponses != null ? List.from(topUpstreamResponses!.map((x) => Map.from(x).map((k, v) => MapEntry(k, v)))) : null, "top_upstreams_avg_time": topUpstreamsAvgTime != null ? List.from(topUpstreamsAvgTime!.map((x) => Map.from(x).map((k, v) => MapEntry(k, v)))) : null, "dns_queries": List.from(dnsQueries.map((x) => x)), "blocked_filtering": List.from(blockedFiltering.map((x) => x)), "replaced_safebrowsing": List.from(replacedSafebrowsing.map((x) => x)), "replaced_parental": List.from(replacedParental.map((x) => x)), "num_dns_queries": numDnsQueries, "num_blocked_filtering": numBlockedFiltering, "num_replaced_safebrowsing": numReplacedSafebrowsing, "num_replaced_safesearch": numReplacedSafesearch, "num_replaced_parental": numReplacedParental, "avg_processing_time": avgProcessingTime, }; }