RestSharp deserialize JSON content(represent an object contains an byte array) error

前端 未结 3 612
夕颜
夕颜 2021-02-18 19:24

The Client side receives a formal JSON content \"{\\\"Id\\\":[1,2,3],\\\"Size\\\":56}\", but get an error in deserialization the byte array.

1 Error occurs

3条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-02-18 20:03

    I have run into this issue, too. My solution was to use RestSharp to perform a raw execute and use Json.NET to deserialize the result:

    var response = client.Execute(request);
    var keyResponse = JsonConvert.DeserializeObject(response.Content);
    

    keyResponse should now be an instance of your key class deserialized from the JSON content.

提交回复
热议问题