I'm coming today for a little problem where I'm stuck.
I'm making a c# xamarin app and this one receives messages (JSON) from my server. The thing is, this message contains 2 fixes variables (String Descrption, Int StatusId). However, a third value is put in this message. This value can be either an object or a range of object. It means that my class can be the two following possibilities:
Case 1 -> I got an object as Result
public class Result
{
public string name { get; set; }
}
public class RootObject
{
public string Description { get; set; }
public Result Results { get; set; }
public int StatusId { get; set; }
}
Case 2 -> I got a list of results as List<Result>
public class Result
{
public string name { get; set; }
}
public class RootObject
{
public string Description { get; set; }
public List<Result> Results { get; set; }
public int StatusId { get; set; }
}
Of course, it's all time a Result object which is get, however, it can be either alone or such as a list.
How can I deserialize this object JSON into the right class if this object can have two possibilities of unserialization?