❔ Serialize inheriting types as a parent type
Hi! I have this class to group all localization types
sample localization type
and when i try to serialize it
I get
5 Replies
I guess its due to Location not having any properties but how can i go around it
If you add this attribute on Location, you'll get what you want:
This will add
"$type":"Address",
which will be referenced when deserializing
If you ever want to be able to serialize an Address (that is specifically typed as such) and then deserialize it as a Location, you'll have to add the same attribute to the Address classThank you! It was exactly what I needed. Interesting how it is done. I was able to apply it to all derived classes ❤️
👍
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.