Last active
May 8, 2020 06:12
-
-
Save emanuelefirmani/54065e631312d30da61386ebcd96306a to your computer and use it in GitHub Desktop.
RestSharp JsonDeserializer is not correctly deserializing the response. Here is a comparison with Newtonsoft
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Linq; | |
using RestSharp; | |
using RestSharp.Serialization.Json; | |
using Xunit; | |
namespace JsonSerialization | |
{ | |
public class UnitTest1 | |
{ | |
private const string json = @"{""panes"":{""filter"":{""records"":[{""data"":{""customernumber"":""10002""}}]}}}"; | |
[Fact] | |
public void newtonsoft() | |
{ | |
var actual = Newtonsoft.Json.JsonConvert.DeserializeObject<FilterBaseModel>(json); | |
Assert.Equal("10002", actual.Panes.Filter.Records.First().Data.Number); | |
} | |
[Fact] | |
public void restsharp() | |
{ | |
var actual = (new JsonDeserializer()).Deserialize<FilterBaseModel>(new RestResponse {Content = json}); | |
Assert.Equal("10002", actual.Panes.Filter.Records.First().Data.Number); | |
} | |
} | |
} |
Author
emanuelefirmani
commented
Apr 4, 2020
Where is your FilterBaseModel
model?
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment