Finally I got this to work. OdataLib does indeed support this by the IEEE754Compatible parameter. It check's the response Content-Type header to see if the parameter is present.
The thing is, that the header value doesn't automatically get propageted to the response header by the web api framework. You have to do it on your own. I've build an ODataController derived class that patches the IEEE754Compatible parameter into the Content-Type header of the response like so:
public abstract class ODataControllerIEEE754Compatible : ODataController
{
private void PatchResponse(HttpResponseMessage responseMessage)
{
if (responseMessage != null && responseMessage.Content != null)
{
if (this.Request.Content.Headers.GetValues("Content-Type").Any(
h => h.Contains("IEEE754Compatible=true")))
{
responseMessage.Content.Headers.TryAddWithoutValidation(
"Content-Type", "IEEE754Compatible=true");
}
}
}
public override Task<HttpResponseMessage> ExecuteAsync(
HttpControllerContext controllerContext, CancellationToken cancellationToken)
{
var response = base.ExecuteAsync(
controllerContext, cancellationToken);
response.Wait(cancellationToken);
PatchResponse(response.Result);
return response;
}
}
Now by sending the IEEE754Compatible=true parameter in the Content-Type Header I receive all long values serialized as JSON strings:
GET http://localhost/some/url HTTP/1.1
OData-Version: 4.0;
Content-Type: application/json;odata.metadata=minimal;IEEE754Compatible=true;charset=utf-8
Cache-Control: no-cache
HTTP/1.1 200 OK
Content-Type: application/json;odata.metadata=minimal;IEEE754Compatible=true
Server: Microsoft-HTTPAPI/2.0
OData-Version: 4.0
{
"@odata.context":"http://localhost/some/url","value":[
{
"ID":"4527895973896126465", ...