Closed JoanSchi closed 9 months ago
I believe this commit changed the behavior such that a portion of the workaround is no longer necessary: https://github.com/google/json_serializable.dart/commit/5422fd47d0aec9fc7e9f0adbaa0ac368b067cde2
It is a partial fix for https://github.com/google/json_serializable.dart/issues/396. My PR is out of date. I'd have to look into it some more to see exactly how much of that issue it addresses.
Hi,
If json_serializable is used with IMap a Type error occurs when string is converted in the into bool / int/ double (num) or duration (FromJson). However DateTime, BigInt or Uri for example are parsed as expected.
json_serializable: ^6.7.0 fast_immutable_collections: ^9.1.5
FromJson Looking to the generated code some types are not parsed correctly with the function FromJson:
Type error IMap<X, String>.fromJson X = int: (value) => value as bool, X = bool: (value) => value as bool, X double: (value) => (value as num).toDouble(),
Works good IMap<X, String>.fromJson X: (value) => DateTime.parse(value as String), X: (value) => BigInt.parse(value as String),
ToJson I do not known if it is necessary, but not everything is converted to string:
Not converted to string (problem?): double/int/bool: (value) => value (Should this not be a String?)
Converted to string (works good) DateTime: (value) => value.toIso8601String() BigInt: (value) => value.toString(),
If this is resolved, I can resolve https://github.com/marcglasberg/fast_immutable_collections/issues/58.
Thank you.
Example
SerializableExample
Generator code