Open RobTF opened 3 years ago
@RobTF You are right. ODL uses its own JSON writer/reader. ODL own writer/reader was designed and implemented before the Newtonsoft.JSON and System.Text.JSON.
Even though, ODL provides the IJsonWriterFactory and IJsonReaderFactory that you can customize.
Hi Sam,
Thanks for the details - those interfaces look very low level though. Do you have any examples of an implementation whereby a particular data type is serialized/deserialized in a different way?
To be specific, we are working with the Geometry types from the NettopologySuite assemblies, as this is what EF Core works with, but are having issues getting these out of the ODATA endpoints.
Hi @xuzhg, I just noticed that 8.0.1 of the library is now released and now exposes some classes such as ODataSerializerProvider
. Will this version be able to help with the issue above?
Maybe create your own formatter ? I built my own for CSV, XML and Excel dumps from OData. I don't see why this wouldn't work for JSON too.
Hi @RobTF, did you find the solution? IJsonWriter is quite a handful to implement.
Looks like this might now be the solution: Override payload serialization and deserialization in odatalib - OData | Microsoft Learn
Hi,
I see there is a new package for adding Netwonsoft JSON so I'm guessing there are available extensibility points for controlling the JSON serialization.
We are using System.Text.Json, but would like to customise how certain entities are serialized/deserialized. The OData library appears to ignore the normal ASP.NET Core MVC JSON settings, so is there some other way of doing this?
many thanks,