当我阅读readme.txt获得最新的RestSharp时:
*** IMPORTANT CHANGE IN RESTSHARP VERSION 103 ***
In 103.0, JSON.NET was removed as a dependency.
If this is still installed in your project and no other libraries depend on
it you may remove it from your installed packages.
There is one breaking change: the default Json*Serializer* 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 client:
var client = new RestClient();
client.JsonSerializer = new YourCustomSerializer();
The default Json*Deserializer* is mostly compatible, but it does not support
all features which Json.NET has (like the ability to support a custom [JsonConverter]
by decorating a certain property with an attribute). If you need these features, you
must take care of the deserialization yourself to get it working.Im已经在nu包管理器中安装了Newtonsoft.Json,我试图将Json.NET注册到客户端变量,但没有工作。这是我的代码:
private void Form1_Load(object sender, EventArgs e)
{
var client = new RestClient("http://homestead.app/vendor");
client.JsonSerializer = new JsonSerializer(); <-- HERE IS THE ERROR
var request = new RestRequest("", Method.GET);
IRestResponse response = client.Execute(request);
var content = response.Content; // raw content as string
textBox1.Text = content;
}client.JsonSerializer属性不可用。
请帮帮我。谢谢
发布于 2017-10-05 12:07:47
新的readme.txt至少在GitHub中被更新,但是包仍然包含旧的代码。
因此,@TcKs的答案是正确的:
var request = new RestRequest();
request.JsonSerializer = new Shared.JsonSerializer();
var client = new RestClient();
client.Post(request);https://stackoverflow.com/questions/43485991
复制相似问题