This is my JSON:
"Dt": {
"20171021": {
"abc": "-"
},
"20171022": {
"abc": "-"
},
"20171023": {
"abc": "-"
},
"20171024": {
"abc": "-"
},
"20171025": {
"abc": "-"
}
}
The properties inside Dt is all dynamic. They are all dates but in string format. So I am thinking if I would need a List object but how would JSON.Net map this into List? I am thinking of class structure something similar to:
public class Dt
{
public List<RealDate> RealDates { get; set;}
}
public class RealDate
{
public string Date{ get; set;} //to hold "20171021"
public Tuple<string, string> Keys {get; set;} // to hold abc as Key1 and - as Key2
}
Any help is appreciated.
That look like there is no Dt
, and the thing that currently has a Dt
should actually have:
public Dictionary<string, Foo> Dt { get; set;}
where Foo
is:
class Foo {
public string abc {get;set}
}
You would then post-process this to turn the DTO model (the serialization model) into your actual model.
Remember: any time that there is even a minor difference between what the serialized data looks like, and what your domain model looks like: add a DTO model, and just map between them manually. It'll save your sanity.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments