By Default when we serialize an object to a json string format, it will use the object property name along with its case. I.e. if i have a property named "MyString" = "TestString" the json format will be
{"MyString":"TestString"} however sometimes we want to have the property name to be camel casing like
{"myString":"TestString"}
Here is how to do it:JsonConvert.SerializeObject(obj, Formatting.None,
new JsonSerializerSettings
{ContractResolver = new CamelCasePropertyNamesContractResolver()})
References:http://stackoverflow.com/questions/2789593/force-lowercase-property-names-from-json-in-asp-net-mvc
No comments:
Post a Comment