I want to define a contract for a DTO which a consuming API project will implement and return as JSON.
From my perspective there are three concerns here:
- The properties defined by the contract
- The implementation (for example, this might be an Entity Framework POCO)
- The serialization metadata which defines the returned JSON
I'd like to define these three parts separately, but to the best of my knowledge I have to add the serialization decoration (DataMember
attributes etc) in the implemtation of my contract. Which means the implementation is coupled with the JSON representation.
Is it possible to separate this serialization metadata into a separate class?