StatisticsEntity.fromJson constructor

StatisticsEntity.fromJson(
  1. dynamic data
)

Implementation

StatisticsEntity.fromJson(data) {
  Map<String, dynamic> json =
      data is Map ? data.cast<String, dynamic>() : jsonDecode(data);
  appCpu = json['appCpu'];
  systemCpu = json['systemCpu'];
  rtt = json['rtt'];
  upLoss = json['upLoss'];
  downLoss = json['downLoss'];
  sendBytes = json['sendBytes'];
  receiveBytes = json['receiveBytes'];
  if (json['localArray'] != null && json['localArray'].length > 0) {
    List<LocalStatisticsEntity> tempData = [];
    for (var d in json['localArray']) {
      tempData.add(LocalStatisticsEntity.fromJson(d));
    }
    localArray = tempData;
  }
  if (json['remoteArray'] != null && json['remoteArray'].length > 0) {
    List<RemoteStatisticsEntity> tempData = [];
    for (var d in json['remoteArray']) {
      tempData.add(RemoteStatisticsEntity.fromJson(d));
    }
    remoteArray = tempData;
  }
}