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

'hasOwnProperty' in javascript -

How to put a lock and transaction on table using spring 4 or above using jdbcTemplate and annotations like @Transactional? -

java - How to implement an entity bound odata action in olingo v4.3 -