google / google/json_serializable.dart
Can multiple fields have same @JsonKey name?
- Dominant language
- Dart
- Stars
- 1.6k
- Forks
- 461
- Avg merge
- 45m
- Merged PRs (30d)
- 1
Description
I'm using JsonSerializable for json request parsing from Django server where I user content_type feature.
That means that I have generic foreign relationship between Django models which consist of object_id, (Primary key of entity in foreign relationship) content_type (table name of entity in foreign relationship) and content_object (object itself that is referenced).
I would like to have in Flutter response class (@JsonSerializable()) to have multiple fields (final ResponseType1 responseType1; final ResponseType2 responseType2; ...) which have same @JsonKey(name: 'content_object') for each one. There will always be single field of (ResponseType1, ResponseType2, ...) present and rest will be null. I want to only correct one to be parsed and rest of fields to be left with null value. Is that possible?
Contributor guide
Assessment
This issue has not been assessed yet.