* Use `JsonConverter`
https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonConverter-class.html
* Use `JsonKey` fields `fromJson` and `toJson`
https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonKey/fromJson.html
https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonKey/toJson.html
* Set `JsonSerializable.genericArgumentFactories` to `true`
https://pub.dev/documentation/json_annotation/latest/json_annotation/JsonSerializable/genericArgumentFactories.html
以上提示了三种方式。
第一种:使模型类继承JsonConverter。
第二种:使用注解@JsonKey
和方法fromJson
与 toJson
。
第三种:在注解@JsonSerializable中设置参数genericArgumentFactories为true。
网友评论