Im having Json like this:
{
"data": {
"50014992": {
"value1": "fr",
"value2": 1378928660,
"value3": 500149927
},
"500149928": {
"value1": "fr",
"value2": 1378928660,
"value3": 500149927
},
"50014999": {
"value1": "fr",
"value2": 1378928660,
"value3": 500149927
},
"50014991": {
"value1": "fr",
"value2": 1378928660,
"value3": 500149927
}
}
}
And i tried to Deserialize it via Newtonsoft Json like this:
public class Test
{
public Data data { get; set; }
public class Data
{
public Dictionary<int, Values> values { get; set; }
}
public class Values
{
public string value1 { get; set; }
public int value2 { get; set; }
public int value3 { get; set; }
}
}
The Deserialisation doesnt throw an error but values is always NULL
How do i deserialize multiple objects with different keys nested in another object ?
val1,val2,val3properties. And where are they in your Json data? Nowhere. Your Json data does not have val1, val2, nor val3 properties. What do you expect Json.Net to do; read your mind? ;-)Dictionary<string, Values>.... and laso the fields in Values should have exact name as in json, your Data in Json is not a class, it is a Dictionary itself