How do I replace the OData V4 default Json Serializer with NewtonSoft's Json Serializer?

前端 未结 2 1942
抹茶落季
抹茶落季 2021-02-09 02:56

I have a class that contains a List of DynamicObjects. I have a unit test that confirms that the Newtonsoft Json Serializer/Deserializer handles this correctly. However, the d

2条回答
  •  梦谈多话
    2021-02-09 03:50

    You have to create a custom DataWriter, for example NewtonsoftJsonDataWriter:ODataWriter.

    Have a look there : tutorial-sample-odatalib-custom-payload-format

    In the example it's a Csv writer which is implemented, I think you'll then be able to override its methods WriteStart, WriteHeader, WriteEntry and WriteEnd with a simple Json.Convert().

提交回复
热议问题