-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Featurerequest: Typenamehandling #6
Labels
enhancement
New feature or request
Comments
Hey Niklas, Suggested solution has been implemented. Please consult the unit tests on how to resolve your use case. btw, thank you for feedback and really useful edge cases. |
Hello @k-paxian, man, you're faster than light! 🥇 But I have one question left, would something like this also be possible? @jsonSerializable
class CEO<TBusiness extends Business> {
TBusiness business;
String fullName;
CEO(this.fullName, this.business);
}
test(
"Should dump typeName to json property when"
" @JsonSerializable(includeTypeName: true)", () {
// given
final john = CEO<Startup>("John", Startup(10));
// when
final String json = JsonMapper.serialize(john);
final CEO<Business> target = JsonMapper.deserialize(json);
// then
expect(target.business, TypeMatcher<Startup>());
}); Thanks, Niklas |
HerrNiklasRaab
added a commit
to HerrNiklasRaab/dart-json-mapper
that referenced
this issue
Mar 2, 2019
Closed
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Sorry for coming up here again :). But...
I am also in a situation where I need to handle something like this:
The serializer should be able to, get the current type, save it in a JSON property, for example, "$type". And can create those types based on the "$type" property.
Newtonsoft.NET is handling this very pretty: https://www.newtonsoft.com/json/help/html/SerializeTypeNameHandling.htm
Because you are using a kind of "reflection", and not this complicated code generation JSON stuff, this should be possible right?
If you need any help, I am willing to do, but I've never contributed to an open source project, so you are dealing with a noob :).
Thanks and a happy day,
Niklas
The text was updated successfully, but these errors were encountered: