I have the following JSON object:
{
"entity": "Customer",
"id": "XXX",
"isActive": "1",
"createdTime": "2018-01-30T18:56:51+02:00",
"updatedTime": "2019-01-05T02:15:17+02:00",
and the following DTO class:
public class Customer
{
public string Id { get; set; }
public bool IsActive { get; set; }
public DateTime CreatedTime { get; set; }
public DateTime UpdatedTime { get; set; }
}
and code for deserialization:
var jsonResponse = JObject.Parse(customerString);
JToken array = jsonResponse["response_data"];
List<Customer> result = (List<Customer>)array.ToObject(typeof(List<Customer>));
but I have a problem with IsActive
property, because json object has 1 or 0 values, but I want to have boolean. How to write JsonSerializer to do it?