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

前端 未结 2 760
不知归路
不知归路 2021-02-09 03:30

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条回答
  •  慢半拍i
    慢半拍i (楼主)
    2021-02-09 03:37

    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().

提交回复
热议问题