[英]Sending Restsharp reponse to a class
I'm trying to send the content of this API response into a custom response class.我正在尝试将此 API 响应的内容发送到自定义响应 class 中。 This produces a parsing error.
这会产生解析错误。 Is there an additional conversion needed before the RestSharp response works with Newtonsoft?
在 RestSharp 响应与 Newtonsoft 一起使用之前,是否需要进行额外的转换? The class has three strings which are meant to grab the three members of the JSON with the same name.
class 具有三个字符串,用于抓取同名的 JSON 的三个成员。
IRestResponse response = client.Execute(request);
<CLASSNAME> content = JsonConvert.DeserializeObject<CLASSNAME>(response.ToString());
The parsing error is "'Unexpected character encountered while parsing value: R. Path '', line 0, position 0.'" My class is as follows:解析错误是“'解析值时遇到意外字符:R。路径'',第0行,position 0.'”我的ZA2F2ED4F8EBC2CBB4C21A29DC40AB61D如下:
public class Response
{
public string name { get; set; }
public string msg { get; set; }
public string code { get; set; }
}
The JSON is as follows: JSON如下:
{
name:
msg:
code:
...bunch of other stuff...
}
Oh I found it.哦,我找到了。 It has to be Response.Content that is deserialized.
它必须是反序列化的 Response.Content。 That's where the JSON is.
这就是 JSON 所在的位置。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.