C# DataContract force PascalCase output

275 views Asked by At

The DataContract likes to accept the input properties in PascalCase (as the property names are in PascalCase as well in C#) unless I manually set the property name to camelCase (using JsonProperty). But doesn't the same doesn't let me output in PascalCase (as I would like to maintain consistency in my input and output serialization).

In short, how can I ensure the output of my datacontract serialization is in PascalCase and not camelCase (the latter is the default for me).

I have tried using [DataMember(Name = "camelCaseName")] and also [JsonProperty("camelCaseName")] but none of them work (although the latter works to take input into the data contract in camelCase, but not the output).

What am I missing here?

0

There are 0 answers