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 deserialize viewmodel structured 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 , child details object using dynamic object that:
var model = json.model.toobject<myviewmodel>; var details = json.serviceinfo.toobject<detailsvm>; however, can't find way extract list of detailsitems json. property null in model. advice on how extract child enumerable object appreciated. array, list, enumerable - either way work.
make model follows:
public class myviewmodel { int id { get; set;} decimal amount { get; set; } detailsvm details { get; set;} ienumerable<detailitem> detailsitemslist { get; set; } } then change json send collection named detailsitemslist.
the model's attribute name must match name given in json.
Comments
Post a Comment