Below is my class :
public class Categories
{
public List<Categories> Subcategories { get; set; }
public List<Locations> Locations { get; set; }
}
public class Locations
{
public List<Coordinates> Coordinates { get; set; }
}
public class Coordinates
{
public int Id { get; set; }
public int X { get; set; }
public int Y { get; set; }
}
Now Coordinates contains records like below :
[0] : Id:0
X:0
Y:0
[1] : Id:1
X:100
Y:200
[2] : Id:2
X:300
Y:400
I am receiving 1 json string which I am deserializing like below :
var data = JsonConvert.DeserializeObject<List<Categories>>(json);
Now what I want to do is I want to ignore record from coordinates whose Id value is 0 while deserializing json in List of categories.
I know I can loop on to this data and then remove records from Coordinates where Id == 0
but I am trying to avoid this loop and would like to know that is there any way to do achieve this while deserialization of string in to class?