{
"apple": {
"A": "xyz",
"B": "abc",
"C": "jkl"
},
"banana": {
"A": "lotus",
"B": "oil",
"C": "cat"
}
}
This is my JSON and below is my model class where I want to map the JSON data.
public class Wrapper
{
public Dictionary<string, item> fruits{ get; set; }
}
public class item
{
public string A{get; set;}
public string B{get; set;}
public string C{get; set;}
}
when I am using the following code to deserialize the Json string I am getting null as response.
var value=Newtonsoft.Json.JsonConvert.DeserializeObject<Wrapper>(jsonString);
fruits. Your JSON doesn't define an object with afruitsproperty. Your JSON would have to be{ "fruits": { "apple": {/*...*/}, "banana": {/*...*/} }.