I have an action that returns a JsonResult in my ASP.Net MVC4 application. I'm setting the Data property to an array of pre-defined classes. My issue is that I want to serialize with different property names. No matter what attributes I use, the object is serialized with the pre-defined property names. I've tried the following with no results:
[DataMember(Name = "iTotalRecords")]
[JsonProperty(PropertyName = "iTotalRecords")]
public int TotalRecords { get; set; }
I know "iTotalRecords" seems silly, but this action is for supporting a jQuery plugin that expects "iTotalRecords" and not "TotalRecords". Of course, I want to use names that make sense in my code-behind.
What serializer is used to parse JsonResult? Is there anything I can do or do I have to re-think returning JsonResult as an action result?