c# - How can I set a different serialized name and deserialized name in MVC? -
i have class [datacontract]
, [datamember]
attributes on it. set name on origin
property custom variables
that's api i'm calling provides. problem is, solves deserialization of object. when comes time serialize object, want serialize origin
property origin
.
[datacontract] public class request { ... [datamember(name = "custom variables")] public origin origin { get; set; } }
for example, want deserialize this:
{ ... "custom variables": { "url": "url_here", "origin": "origin_here" } }
and turn upon serialization:
{ ... "origin": { "url": "url_here", "origin": "origin_here" } }
how can this? there way without writing custom serializer of properties on object?
Comments
Post a Comment