Hello, I get such JSON and want to deserialize it into my C# object.
JSON (partially):
{
"Quotes": [
{
"QuoteId": 1,
"MinPrice": 119,
"Direct": true,
"OutboundLeg": {
"CarrierIds": [
851
],
"OriginId": 81727,
"DestinationId": 60987,
"DepartureDate": "2019-04-01T00:00:00"
},
"QuoteDateTime": "2019-03-10T19:27:00"
}
],
"Places": [
{
"PlaceId": 60987,
"IataCode": "JFK",
"Name": "New York John F. Kennedy",
"Type": "Station",
"SkyscannerCode": "JFK",
"CityName": "New York",
"CityId": "NYCA",
"CountryName": "United States"
},
{
"PlaceId": 81727,
"IataCode": "SFO",
"Name": "San Francisco International",
"Type": "Station",
"SkyscannerCode": "SFO",
"CityName": "San Francisco",
"CityId": "SFOA",
"CountryName": "United States"
}
]
}
My classes:
public class MyQuotes
{
public List<Quote> Quotes { get; set; }
public List<Place> Places { get; set; }
}
public class Quote
{
public int QuoteId { get; set; }
public List<MyOutboundLeg> OutboundLeg { get; set; }
}
public class MyOutboundLeg
{
public List<int> CarrierIds { get; set; }
public int OriginId { get; set; }
}
public class Place
{
public string PlaceId { get; set; }
public string CountryName { get; set; }
}
}
What I have tried:
var body = ApiTestContext.Response.Content.ReadAsStringAsync().Result;
MyQuotes myQuotes = JsonConvert.DeserializeObject<MyQuotes>(body);