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 -

python - ValueError: No axis named 1 for object type <class 'pandas.core.series.Series'> -

java - How to provide dependency injections in Eclipse RCP 3.x? -