-
-
Notifications
You must be signed in to change notification settings - Fork 57
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
Support of per inheritance level discriminators #60
Comments
Hi @sanzor This use case is not yet supported. If we look into the serialized data we can see that there are in fact three discriminator fields serialized: {"$GameKind":0,"$PayloadKind":1,"Kind":0} Currently when It's a feature that could be interesting to include in further release. I might have a look when I'll have some free time, or you can try to hack into this library and make a PR ;-) At first look it seems that adding a loop in the function GetType might be ok |
Hello,Thank you for your fast response , i will definetly look into it. But do you know what could be an alternative solution to this problem ? Maybe System.Dynamic ?
Adrian
Sent from Yahoo Mail on Android
On Sat, 23 Feb 2019 at 16:47, Emmanuel Counasse<[email protected]> wrote:
Hi @sanzor
This use case is not yet supported. If we look into the serialized data we can see that there are in fact two discriminator field serialized:
{"$GameKind":0,"$PayloadKind":1,"Kind":0}
Currently when JsonSubtypes resolve the first discriminator it doesn't look if the resolved type is also annoted with JsonSubtypes.KnownSubType, that's wy it doesn't work.
It's a feature that could be interesting to include in further release. I might have a look when I'll have some free time, or you can try to hack into this library and make a PR ;-)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub, or mute the thread.
|
I have managed to solve this by using your library.I would keep an abstract field in the root object only to be overridden in the leaf's.I would use this Source code is here: |
If i have a 3-level hierarchy and i place a JsonProperty at first and second level
Can i deserialize like:
So far i get an error and i can only deserialize it like this:
Animal a=JsonConvert.DeserializeObject<Dog>();
P.S My question is better seen here https://stackoverflow.com/questions/54835920/deserializing-with-multiple-levels-of-polymorphic-type-hierarchy
Sample code:
The text was updated successfully, but these errors were encountered: