Incompatible with json_serializable toJson/fromJson: issue _safeKeyFromJson #58
Labels
bug
Something isn't working
good first issue
Good for newcomers
help wanted
Extra attention is needed
Hi
Thank you for the great package.
Issue:
I tried to use IMap<DateTime,something> with json_serializable 6.7.0 and FIC 9.1.5. Unfortunately I get a string casting error, probably the same issue as #39. Therefore I made a example with IMap, Map with DateTime and Enum as key.
I also made a example and tested the example with a suggested solution.
Problem:
The json_serializable converts the string in the desired type, while _safeKeyToJson tries again to convert the already converted type. In my case: instead of DateTime.parse(string) it will be DateTime.parse(DateTime) at this cause the casting error. (See generated code)
Suggestion for Solution
Because the type convertion is already done by json_serializable, a possible solution could be: removing _safeKeyFromJson. This works fine and is compatible with serializable and freezed package. (Could _safeKeyFromJson be a option {bool safeKey = false/true} ?)
Temperal fix:
Test Example
Convertion to json and back:
The text was updated successfully, but these errors were encountered: