Skip to content
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

What are the requirements for "JsonDiscriminatorProperty" and "JsonDiscriminatorValue"? #30

Open
runeksvendsen opened this issue Apr 15, 2019 · 0 comments

Comments

@runeksvendsen
Copy link

I would like to serialize and deserialize multiple instances of a common interface. To do this, the README says I should use JsonDiscriminatorProperty and JsonDiscriminatorValue. However, it doesn't say what these actually do, or what the requirements are for using these decorators, so I will ask here:

Is it required that my superclass/interface has a property that describes the subclass type? For example, the Animal type in the example has a type:AnimalType field (pointed to by the JsonDiscriminatorProperty decorator). Is this required for (de)serialization to work?

In other words:

  1. Do I have to create a distinct value (e.g. via an enum) for all the subtypes of the interface/superclass I want to serialize?
  2. Do all instances need a property that is set to this value?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant