I am using a Kendo Scheduler in my app to pull data from my database using a Web Api. I created a Web Api function and just hard coded some data in there to be sure the Kendo Sc
If you are using Json.NET 9.0.1 or later, you can specify a naming strategy for a specific type by marking it with [JsonObject(NamingStrategyType = typeof(TNamingStrategy))]. This overrides the naming strategy of CamelCasePropertyNamesContractResolver
. In your case you want DefaultNamingStrategy:
[JsonObject(NamingStrategyType = typeof(DefaultNamingStrategy))]
public class EventViewModel
{
public int Id { get; set; }
public string Title { get; set; }
public string Description { get; set; }
public bool IsAllDay { get; set; }
public DateTime Start { get; set; }
public DateTime End { get; set; }
public string StartTimezone { get; set; }
public string EndTimezone { get; set; }
public string RecurrenceRule { get; set; }
public string RecurrenceException { get; set; }
}
Note that the [JsonProperty("name")]
attributes are no longer needed.
On your global contract resolver, there is also a property NamingStrategy. Setting NamingStrategy.OverrideSpecifiedNames to false
also prevents [JsonProperty("name")]
names from being overridden globally. For CamelCasePropertyNamesContractResolver
it seems the default is true
, which is the cause of your problem.