Setting IgnoreSerializableAttribute Globally in Json.net

前端 未结 4 2067
萌比男神i
萌比男神i 2020-12-10 04:07

I\'m working on a ASP.NET WebApi (Release Candidate) project where I\'m consuming several DTOs that are marked with the [Serializable] attribute. These DTOs are outside of m

4条回答
  •  悲&欢浪女
    2020-12-10 04:30

    I found easy way to get rid of k__BackingField in the names.

    This fragment should be somewhere in the Application_Start() in Global.asax.cs:

    JsonSerializerSettings jSettings = new Newtonsoft.Json.JsonSerializerSettings();
    GlobalConfiguration.Configuration.Formatters.JsonFormatter.SerializerSettings = jSettings;
    

    Looks like the default setting takes care of it.

提交回复
热议问题