I have JSON like this:
{"rows":
{
"1":{"rowNumber":1,"productID":"100"},
"2":{"rowNumber":2,"productID":"101"},
"3":{"rowNumber":3,"productID":"102"}
}
}
I need to build domain model.
For example:
class Row
{
public int rowNumber{get; set;}
public string productID{get; set;}
}
Root object
class RootObject
{
public ? ? rows {get; set;}
}
What kind of type have to be rows propperty?
The answer is
public Dictionary<int, Row> rows { get; set; }
and use
JsonConvert.DeserializeObject<RootObject>(json);
for deserialization. Where JsonConvert is from Newtonsoft library.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With