I have this simple JSON and I was making deserializing this JSON, so I can get the elements. This is the JSON I have :
{
"QuestionIDs": [
"QID1",
"QID3"
],
"QuestionDefinitions": {
"Question1": {
"DETag": "Q1",
"Config": {
"QDescription": "UseText"
},
"COrder": [
"1",
"2",
"3"
],
"Validation": {
"Settings": {
"ForceResponse": "OFF",
"ForceResponseType": "ON",
"Type": "None"
}
}
}
},
"NextButton": null,
"PreviousButton": false
}
This is the code I've written :
[DataContract]
public class RootObject
{
[DataMember]
public Dictionary<string, Dictionary<string, string>> QuestionDefinitions { get; set; }
[DataMember]
public List<string> QuestionIDs { get; set; }
}
QuestionIDs
is working just fine. But, QuestionDefinitions
isn't working. It says that it is an empty sequence. I'm not sure what's wrong.
I want to be able to access QuestionDefinitions
.
I tried with Json.Net
. Facing the same issue. I was able to get the simple elements that are out. But, couldn't get to access the QuestionDefinitions
.
Any help would be appreciated.
EDIT :
I also tried implementing this class like this :
[DataContract]
public class QuestionDetails
{
[DataMember]
public string DETag { get; set; }
[DataMember]
[DataMember]
public List<Configuration> Config { get; set; }
[DataMember]
public List<string> ChoiceOrder { get; set; }
[DataMember]
public List<Validation> Validation { get; set; }
[DataMember]
public List<string> COrder { get; set; }
[DataMember]
public string NextButton { get; set; }
[DataMember]
public string PreviousButton { get; set; }
}
[DataContract]
public class RootObject
{
[DataMember]
public Dictionary<string, QuestionDetails> QuestionDefinitions { get; set; }
[DataMember]
public List<string> QuestionIDs { get; set; }
}