Open JoanSchi opened 1 year ago
@JoanSchi I don't actually use json_serializable. The serialization code was actually contributed by others, so I wouldn't know how to fix it or test it.
Since you already have a solution, could you please create a PR? Thanks!
@marcglasberg
Thanks
I made PR, however I tested all the Types. BigInt DateTime, uri and String works fine, nevertheless int double bool results in a type error. Unfortenately these types are not parsed correctly by json_serializable.
I filled in a issue:
https://github.com/google/json_serializable.dart/issues/1332
Depending on the response of this issue I will make a fix. (It takes a little bit longer)
Nevertheless I learned to make a PR :)
Hi @JoanSchi could you please tell me the status of this solution?
Should I apply it? Your issue in json_serializable
seems to have been fixed, right? https://github.com/google/json_serializable.dart/issues/1332
Hi @marcglasberg,
Unfortunately it is not fixed in json_serializable. For a temporal workaround I use a JsonConverter.
For now it is better to leave it as it is.
It won't last very long before macro will be introduced in Dart, with a new json_serializable based on macro's, I hope this fix the issue.
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:
TestMaps: