Can I set a custom JsonSerializer to RestSharp RestClient

非 Y 不嫁゛ 提交于 2019-12-06 08:09:18

There was a mistake in the Readme, it seems.

https://github.com/restsharp/RestSharp/issues/886 https://github.com/restsharp/RestSharp/issues/947

This is how it should be used:

There is one breaking change: the default JsonSerializer is no longer compatible with Json.NET. To use Json.NET for serialization, copy the code from https://github.com/restsharp/RestSharp/blob/86b31f9adf049d7fb821de8279154f41a17b36f7/RestSharp/Serializers/JsonSerializer.cs and register it with your request:

 var request = new RestRequest();
 request.JsonSerializer = new Shared.JsonSerializer();

then you can use it in a client:

 var client = new RestClient();
 client.Post(request);

Source: https://github.com/restsharp/RestSharp/blob/4e239eaa90abcc699f875bbd7a64efe76a995771/readme.txt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!