Let’s say you’re writing a WCF REST service, and in proper C# fashion, your object’s properties start with a capital letter. Then your service is being consumed by Objective-C code or javascript, which call for lowercase. Since WCF uses the DataContractJsonSerializer, you can set a different name for the property to serialize to:
public class MyObject
{
[DataMember(Name = "name")]
public string ObjectName { get; set; }
But for some reason, it’s not working; you still end up with “ObjectName: ‘Yadda’”. I ran into this issue, and the problem turned out to be a missing line of boilerplate:
[DataContract(Name="MyObject")]
public class MyObject
{
[DataMember(Name = "name")]
public string ObjectName { get; set; }
As least as far as I’ve seen, a WCF REST service can chug along just fine without that DataContract parameter in most respects, but if you leave it out, you forego being able to set custom property names. Hope this saved you a headache!