I have a complex json like this:
{
"tests": {
"test1": {
"a": "50",
"b": "60",
"c": "40,",
"d": "..",
"e": "...",
"f": "..",
"g": "..",
"h": "..",
"i": "..",
"j": "..",
"k": "..",
"l": "..",
"m": ".."
},
"tests2": {
"a": "..",
"b": "..",
"c": "..",
"d": "..",
"e": "..",
"f": ".."
},
"tests3": {
"quiz1": {
"a": "07.00.25.00,",
"b": "07.00.04.14,",
"c": "07.00.00.31"
},
"quiz2": {
"a": "...",
"b": "...",
"c": "..."
},
"quiz3": {
"a": "..",
"b": "..",
"c": ".."
}
}
}
}
I am converting it into object model and get this:
public class Test1
{
public string a { get; set; }
public string b { get; set; }
public string c { get; set; }
public string d { get; set; }
public string e { get; set; }
public string f { get; set; }
public string g { get; set; }
public string h { get; set; }
public string i { get; set; }
public string j { get; set; }
public string k { get; set; }
public string l { get; set; }
public string m { get; set; }
}
public class Tests2
{
public string a { get; set; }
public string b { get; set; }
public string c { get; set; }
public string d { get; set; }
public string e { get; set; }
public string f { get; set; }
}
public class Quiz1
{
public string a { get; set; }
public string b { get; set; }
public string c { get; set; }
}
public class Quiz2
{
public string a { get; set; }
public string b { get; set; }
public string c { get; set; }
}
public class Quiz3
{
public string a { get; set; }
public string b { get; set; }
public string c { get; set; }
}
public class Tests3
{
public Quiz1 quiz1 { get; set; }
public Quiz2 quiz2 { get; set; }
public Quiz3 quiz3 { get; set; }
}
public class Tests
{
public Test1 test1 { get; set; }
public Tests2 tests2 { get; set; }
public Tests3 tests3 { get; set; }
}
public class RootObject
{
public Tests tests { get; set; }
}
and using newsoft.json to convert the json into the object model.
Tests versions = Newtonsoft.Json.JsonConvert.DeserializeObject<Tests>(str);
i would like each json object properties to be a dictionary of property at each object.
I know i could use JsonConvert.DeserializeObject<Dictionary<string, string>>(str);
if i had 1 json object but i couldn't find a solution to my case.