According to your JSON data, it has two parts: one is variable (List) and the another is fixed (Map). So you need to think how to deal with that structure, one example:
List<Object> : L
L[0] : List<Object> : K
K[i] : Map<String, Object> : where i = 0.. K.length-1
- convert every element to an instance of Person class
L[1] : Map<String, Object>
- convert this element to an instance of Control class
Respect to classes to use:
import 'package:meta/meta.dart';
import 'dart:convert';
class Person {
Person({
@required this.id,
@required this.mail,
@required this.password,
@required this.name,
@required this.photo,
@required this.dateac,
});
int id;
String mail;
String password;
String name;
String photo;
DateTime dateac;
factory Person.fromRawJson(String str) => Person.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory Person.fromJson(Map<String, dynamic> json) => Person(
id: json["id"],
mail: json["mail"],
password: json["password"],
name: json["name"],
photo: json["photo"],
dateac: DateTime.parse(json["dateac"]),
);
Map<String, dynamic> toJson() => {
"id": id,
"mail": mail,
"password": password,
"name": name,
"photo": photo,
"dateac": dateac.toIso8601String(),
};
}
class Control {
Control({
@required this.fieldCount,
@required this.affectedRows,
@required this.insertId,
@required this.serverStatus,
@required this.warningCount,
@required this.message,
@required this.protocol41,
@required this.changedRows,
});
int fieldCount;
int affectedRows;
int insertId;
int serverStatus;
int warningCount;
String message;
bool protocol41;
int changedRows;
factory Control.fromRawJson(String str) => Control.fromJson(json.decode(str));
String toRawJson() => json.encode(toJson());
factory Control.fromJson(Map<String, dynamic> json) => Control(
fieldCount: json["fieldCount"],
affectedRows: json["affectedRows"],
insertId: json["insertId"],
serverStatus: json["serverStatus"],
warningCount: json["warningCount"],
message: json["message"],
protocol41: json["protocol41"],
changedRows: json["changedRows"],
);
Map<String, dynamic> toJson() => {
"fieldCount": fieldCount,
"affectedRows": affectedRows,
"insertId": insertId,
"serverStatus": serverStatus,
"warningCount": warningCount,
"message": message,
"protocol41": protocol41,
"changedRows": changedRows,
};
}
Generated by https://app.quicktype.io/