How to remove k__BackingField from json when Deserialize How to remove k__BackingField from json when Deserialize json json

How to remove k__BackingField from json when Deserialize


The default WebApi serializer will add that "__BackingField:" syntax to c# auto-properties. Add this to your WebConfig in App_Start to get the cleaner looking json that you might be looking for.

using Newtonsoft.Json;...config.Formatters.JsonFormatter.SerializerSettings = new JsonSerializerSettings();


Automatic Property syntax is actually not recommended if the class can be used in serialization. Reason being the backing field is generated by compiler which can be different each time code is compiled. This can cause incompatibility issues even if no change is made to the class (just recompiling the code).

I think applying DataMember attribute will fix the issue in this case. But I would recommend to use full property syntax, if the class needs to be used in serialization.