OData Serialization (camelCase and custom serialization of types)

Topics: ASP.NET Web API
Mar 1, 2014 at 1:08 PM
My question relates specifically to WebApi 2 + OData.

I'm trying to customize how my fields and certain types are serialized. First of all, although my Edm uses PascalCase I want the JSON data returned from the service to be camelCase. I can easily change this on the Newtonsoft JSON serializer but of course OData doesn't use this. How would I go about doing this?

Secondly, I have a complex type for which I want to control serialization. As an example:
public class Position
   public double Latitude;
   public double Longitude
This will serialize to "Position":{Latitude:xxx,Longitude:yyy}. How could I alter it so 'Position' instances are serialized to "Position":"xxx yyy"?

Mar 10, 2014 at 9:26 AM
It isn't possible to do either of these.