For Example :
For train Availability, sometimes we are getting response , applicableBerthTypes as List in case of multiple berth available such as LOWER,UPPER etc. Sometimes we are getting response as applicableBerthTypes as string in case of only one berth type is available such as SITTING.
Model class will be ,
public class BkgCfg
{
public string acuralBooking { get; set; }
public List<string> applicableBerthTypes { get; set; }
}
JSON Response that we are recieving from Supplier end.
LstrApidata= {"acuralBooking": "","applicableBerthTypes":["LB","MB","UB","SL","SU"]}
Working fine when am trying to deserialize above Json .
LobjBkgCfg = JsonConvert.DeserializeObject<BkgCfg>(LstrApiData);
When supplier sends json as
{
"acuralBooking": null,
"applicableBerthTypes":"LB"
}
getting error when am trying to deserialize above Json.
LobjBkgCfg = JsonConvert.DeserializeObject<BkgCfg>(LstrApiData);
For each and every response, i need to create two model classes , one is for "List" and another one is "string". Is it possible to create one property that accept list as well as string in c# ?