google / google/json_serializable.dart

Allow annotated field with JsonKey.unknownEnumValue to be of type Map

Open
#1,093 3 comments 12 reactions 0 assignees View on GitHub
Dominant language
Dart
Stars
1.6k
Forks
461
Avg merge
45m
Merged PRs (30d)
1

Description

At present, the #585 and PR #691 allows us to annotate `unknownEnumValue` fields of type enum or on Iterable, List, or Set instances of an enum type. Is is possible to support Map ?

Example:

```
@JsonKey(unknownEnumValue: YourEnum.yourUnkownValue)
final Map minWithdrawalAmount;
```

This is currently not possible. Enclosed error shown in terminal when generate the code

```
Error with `@JsonKey` on the `minWithdrawalAmount` field. `unknownEnumValue` can only be set on fields of type enum or on Iterable, List, or Set instances of an enum type.
package:yourfile.dart:19:22

19 │ Map minWithdrawalAmount;
│ ^^^^^^^^^^^^^^^^^^^

```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.