ScrutinFromJson.fromFrenchNationalAssemblyJson constructor

ScrutinFromJson.fromFrenchNationalAssemblyJson(
  1. Map<String, dynamic> _map
)

Mapping from JSON

Implementation

ScrutinFromJson.fromFrenchNationalAssemblyJson(Map<String, dynamic> _map) {
  Map<String, dynamic> json = _map["scrutin"];

  this.uuid = json['uid'];

  this.organeRef = json['organeRef'];
  this.numero = json['numero'];
  this.seanceRef = json['seanceRef'];
  this.dateScrutin = dateFormatter(json['dateScrutin'],
      dateSeparator: "-", format: "YMD", noHour: true);

  Map<String, dynamic> _typeVote = json["typeVote"];
  this.codeVote = _typeVote['codeTypeVote'];
  this.libelleVote = _typeVote['libelleTypeVote'];
  this.majoriteVote = _typeVote['typeMajorite'];

  Map<String, dynamic> _sort = json["sort"];
  this.resultatVote = _sort['code'];

  this.titre = json['titre'];

  Map<String, dynamic> _demandeur = json["demandeur"];
  this.demandeur = _demandeur['texte'];

  Map<String, dynamic> _syntheseVote = json["syntheseVote"];
  Map<String, dynamic> _decompte = _syntheseVote["decompte"];

  this.votedFor = int.tryParse(_decompte['pour']) ?? 0;
  this.votedAgainst = int.tryParse(_decompte['contre']) ?? 0;
  this.votedAbstention = int.tryParse(_decompte['abstentions']) ?? 0;
  this.didNotVote = int.tryParse(_decompte['nonVotants']) ?? 0;

  Map<String, dynamic> _ventilationVotes = json["ventilationVotes"];
  Map<String, dynamic> _organe = _ventilationVotes["organe"];
  Map<String, dynamic> _groupes = _organe["groupes"];

  List<dynamic> _roughJson = _groupes['groupe'];
  List<GroupVotesFromJson> _toPass = [];
  for (var i = 0; i < _roughJson.length; i++) {
    Map<String, dynamic> _toConvert = _roughJson[i];
/*
    print("-- ScrutinFromJson.fromFrenchNationalAssemblyJson - " +
        this.uuid.toString() +
        " - " +
        i.toString());
*/
    _toPass.add(GroupVotesFromJson.fromFrenchNationalAssemblyJson(_toConvert,
        majoriteVoteFromScrutin: _typeVote['typeMajorite']));
  }
  this.groupVotesDetails = _toPass;
}