I have some C# code using ASP.Net MVC, which is making use of Json.Net to serialize some DTOs. In order to reduce payload, I have made use of the [JsonProperty(PropertyName = "shortName")] attribute to use shorter property names during serialization.
This works great when the client is another .Net app or service, as the deserialization puts the object hierarchy back together, using the longer more friendly names, while keeping actual transfer payload low.
The problem comes into play when the client is javascript/ajax through a browser. It makes the request, and gets the json ... but that json is using the shortened less-friendly names.
How can I make the json.net serialization engine ignore the [JsonProperty(PropertyName = "shortName")] attribute programmatically? Ideally, my MVC service is going to sit there running and normally serialize using the shortened property names. When my code detects a particular parameter, I'd like to get the data serialized using the longer names and ignore the [JsonProperty()] attribute.
Any suggestions?
Thanks,
Kevin