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

前端 未结 2 766
不知归路
不知归路 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条回答
  • 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().

    0 讨论(0)
  • 2021-02-09 04:02

    Looked for this before, i don't think it's possible. Kinda like it's not possible to add an XML serializer :-(

    It is possible in Web Api though

    0 讨论(0)
提交回复
热议问题