0
Answer

Dynamic survey from Json

Tony SamDzousa

Tony SamDzousa

7y
201
1
I have a json for survey creation.Based on the json,i need to display the survey form dynamically. I have created the classses to read json.
Please guide me the easy way to continue this
Json sample:
 
{ "dataObj":{ "surveyId":1, "questions":[ { "questionId":7, "questionName":"Picture can help you tell a better story? Snap a photo and share it with us.", "questionType":"IMAGE", "questionSequenceNumber":7, "pageNo":1, "highlightedText":"Snap a photo", "isDynamicText":"N", "answerOptions":[ { "parentQuestion":"5", "parentAnswer":null, "answerOption":null } ] } ] }, "errorCode":0, "errorMessage":"No Error" }
class:
 
public class AnswerOption { [JsonProperty("parentQuestion")] public string ParentQuestion { get; set; } [JsonProperty("parentAnswer")] public object ParentAnswer { get; set; } [JsonProperty("answerOption")] public object Option { get; set; } }  public class Question { [JsonProperty("questionId")] public int QuestionId { get; set; } [JsonProperty("questionName")] public string QuestionName { get; set; } [JsonProperty("questionType")] public string QuestionType { get; set; } [JsonProperty("questionSequenceNumber")] public int QuestionSequenceNumber { get; set; } [JsonProperty("pageNo")] public int PageNo { get; set; } [JsonProperty("highlightedText")] public string HighlightedText { get; set; } [JsonProperty("isDynamicText")] public string IsDynamicText { get; set; } [JsonProperty("answerOptions")] public IList<AnswerOption> AnswerOptions { get; set; } }  public class DataObj { [JsonProperty("surveyId")] public int SurveyId { get; set; } [JsonProperty("questions")] public IList<Question> Questions { get; set; } }  public class Example { [JsonProperty("dataObj")] public DataObj DataObj { get; set; } [JsonProperty("errorCode")] public int ErrorCode { get; set; } [JsonProperty("errorMessage")] public string ErrorMessage { get; set; }