編集:問題なく逆シリアル化できることがわかりました。問題は、実際にループして質問を取得しようとしたときです。「オブジェクト参照がオブジェクトのインスタンスに設定されていません」と同じエラーが発生します。回答があるので投稿を削除できないため、これを編集しているだけです。
//deserialize json
ResponsesList responses = JsonConvert.DeserializeObject<ResponsesList>(_ResponseContent);
if (responses != null)
{
//loop through responses
foreach (ResponsesList.Data data in responses.data)
foreach (ResponsesList.Questions question in data.questions)
foreach (ResponsesList.Answer answer in question.answers)
{
//upsert each response
UpsertResponse(survey_id, data.respondent_id, question.question_id, answer.row, answer.col);
}
}
この行はエラーが発生する場所です
foreach (ResponsesList.Questions question in data.questions)
ここに私がデシリアライズしているクラスがあります
//get_responses
public class ResponsesList
{
public int status { get; set; }
public List<Data> data { get; set; }
public class Data
{
public string respondent_id { get; set; }
public List<Questions> questions { get; set; }
}
public class Questions
{
public List<Answer> answers { get; set; }
public string question_id { get; set; }
}
public class Answer
{
public string row { get; set; }
public string col { get; set; }
}
}