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
{{ message }}
This repository has been archived by the owner on Apr 20, 2020. It is now read-only.
Thanks for sharing this library! I have definitely been wanting to use something like this.
Is it possible to add json serialization to the generated data class?
My specific use-case is that I'd like to use json_serializable. To use it, I'd need to add some boilerplate (toJson and fromJson) to the generated data class; however, the generated data class can't be edited by hand.
The text was updated successfully, but these errors were encountered:
Hmm good question. I guess we could try to add a meta-anmotation like @Annotation(JsonSerializable()) to the mutable class to then add the actual annotation @JsonSerializable() to the generated class.
But I'm not even sure you can add annotations in generated files...
Also, this issue doesn't have the highest priority right now, so it'll take some time until I evaluate/implement this. Of course you're welcome to contribute to the project, if you want to!
In the meantime, you can of course add @JsonSerializable to the mutable class and use User.toMutable().toJson() and User.fromMutable(MutableUser.fromJson(json)) although this is more boilerplate.
Oh and also, take into consideration that static extension methods are actively being worked on by the Dart team right now, so soon you'll be able to define User.toJson() => this.toMutable().toJson() in the original file.
Thanks for sharing this library! I have definitely been wanting to use something like this.
Is it possible to add json serialization to the generated data class?
My specific use-case is that I'd like to use json_serializable. To use it, I'd need to add some boilerplate (
toJson
andfromJson
) to the generated data class; however, the generated data class can't be edited by hand.The text was updated successfully, but these errors were encountered: