You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a Map<Id, int> whose key is a custom class. That class is is annotated with @JsonConverter for converting it to a String. When I run json_serializable over my code, I get the error
[project]: [SEVERE] json_serializable on lib/src/cart.dart:
[project]:
[project]: Could not generate `toJson` code for `items` because of type `Id`.
[project]: Map keys must be one of: Object, dynamic, enum, String, BigInt, DateTime, int, Uri.
Now Id is not one of those types, but by default it will serialise to a String. So should this use can be supported? More info/example below:
❯ dart --version
Dart SDK version: 3.2.5 (stable) (Tue Jan 16 15:02:13 2024 +0000) on "macos_arm64"
I would go even further to say that if a particular type has a toJson / fromJson that returns/takes a String type, then the conversion should be implicit (or perhaps put this behind a configuration parameter?).
I have a
Map<Id, int>
whose key is a custom class. That class is is annotated with@JsonConverter
for converting it to a String. When I run json_serializable over my code, I get the errorNow
Id
is not one of those types, but by default it will serialise to a String. So should this use can be supported? More info/example below:❯ dart --version Dart SDK version: 3.2.5 (stable) (Tue Jan 16 15:02:13 2024 +0000) on "macos_arm64"
Map keys must be one of:
The text was updated successfully, but these errors were encountered: