Hi, all
As you know, since Dart doesn't recommend mirror, we can handle Json serialization&deserialization with SourceGen. However, from my point of view, SourceGen has following weak points:
1. Doesn't support generic type. for example, you defined a Json class like
class UserDataT <T, T1, T2, T3,T4>{
2. Doesn't support customized serialization strategy, like serialization all fields of Json object to string, convert Json object to array, etc. And vice versa for deserialization.
To be more detail, I want serialize the above class to Json composed with all string. That is to say, the age, birthday all will be of string type, instead of the original type like int and datetime.
3. The SourceGen is not so fit with our traditional experience, we may like some way to do as following:
final UserDataT<String, int, String, Child, DateTime> userDataT = JsonParser.fromJson<UserDataT<String, int, String, Child, DateTime>>(jsonDecode(str));
For the above issue, I have implemented a JsonParser based on Kernel transformer. Under the hood, I will transform the dill to generate the customized serialization&deserialization logics.
I am planning to open source this framework, but I am afraid it will be affect by the experience of Kernel transform of Dart. Therefore, with this issue, I urge Dart team to support customization of kernel transform pipeline. I am sure a lot of useful framework will be rising base on this feature.
Thanks,
Jim