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

Popular posts from this blog

Command prompt result in label. Python 2.7 -

javascript - How do I use URL parameters to change link href on page? -

amazon web services - AWS Route53 Trying To Get Site To Resolve To www -