I have a json
file which has either of the following formats:
- Sample 1:
{
"MyOrders": [
{
"order": "my order1",
"url": "tt"
}
]
}
Sample 2:
{
"MyOrders": [
[
{
"order": "my order 1",
"url": "ddfdfd"
},
{
"order": "order 2",
"url": "asdfwe"
}
],
[
{
"order": "my order 3",
"url": "ertrt"
},
{
"order": "my order 4",
"url": "werwe"
}
]
]
}
I have the following code:
InputItems root = JsonConvert.DeserializeObject<InputItems>(myJsonText);
And I have the following classes:
public class InputItems
{
[JsonProperty("MyOrders")]
public List<Order> objects { get; set; }
}
public class Order
{
[JsonProperty("order")]
public string order{ get; set; }
[JsonProperty("url")]
public string url { get; set; }
}
But it works just for the first case. How can I improve it to also cover the second sample format?
Thanks in advance.