I have nested JObject:
{
"model": {
"id": "1",
"amount": "1.00",
"details": {
"tax": "0.10",
"order": "DFG456"
},
"lineItems": [
{
"commodityCode": "abc",
"unitOfMeasure": "pnd",
"quantity": "1",
"uomCost": "1.00",
"taxAmount": "0.10",
"itemTotalAmount": "0.10"
},{
"commodityCode": "xyz",
"unitOfMeasure": "pnd",
"quantity": "2",
"uomCost": "1.00",
"taxAmount": "0.10",
"itemTotalAmount": "0.10"
}
]
} }
I'm trying to deserialize it into my ViewModel that structured like that:
public class MyViewModel {
int id { get; set;}
decimal amount { get; set; }
DetailsVm details { get; set;}
List<DetailItem> DetailsItemsList { get; set; }
}
I have no problem desereializing top model and child details object using dynamic object like that:
var model = json.model.ToObject<MyViewModel>;
var details = json.serviceInfo.ToObject<DetailsVm>;
However, I can't find a way to extract the list of DetailsItems from json. Property is null in the model. Any advice on how to extract the child enumerable object would be greatly appreciated. Array, List, just enumerable - either way would work.