c# - Deserialize to object with custom object property -
i have class so:
public class caretaker { public int id {get; set;} public string name {get; set;} public datetime? datetrained {get; set;} public certification certification {get; set;} public list<certification> expiredcertifications {get; set;} } public class certification { public int id {get; set;} } and json so:
{ "id": 1, "name": "dogtor", "datetrained": "01 feb 2017", "certification": 2, "expiredcertifications": [1,5] } i know json certification should "certification": { "id": 2}, but, don't have access change json have figure out how convert recieve ("certification": 2) object... there way can either javascriptserializer or newtonsoft please?
you this:
public class caretaker { ... [notmapped] [jsonproperty(propertyname = "certification"] public int? certificationid { { return certification?.id; } set { certification = new certification { id = value; } } } [jsonignore] public certification certification {get; set;} ... }
Comments
Post a Comment