我在问一个问题,但没有找到类似的帖子。
我解释一下,我使用 json_serializable,但是 webservice 通过不同的名称键提供了一些相同类型的对象的信息,例如:
@JsonSerializable(explicitToJson: true)
class Group {
Group(
this.id,
this.name,
this.owner,
this.description);
int id;
String name;
User owner; //Here owner are only "id" and "name"
String? description;
...
}
@JsonSerializable()
class User {
User(this.uid, this.nom, this.mail, this.prenom);
String? uid;
late String mail;
String nom;
String? prenom;
...
所以“id”和“uid”是不同的键,但值相同,“name”和“nom”的东西相同。
有什么方法可以指示生成器这可以是相同值的不同键名..?