I have some JSON similar to this coming over from a call to GoToWebinar's API:
[
{
"answer":"The Answer for Question 1",
"question":"1. This is the Question?"
},
{
"answer":"The Answer for Question 2",
"question":"2. This is the Question?"
},
{
"answer":"The Answer for Question 7",
"question":"7. This is the Question?"
},
{
"answer":"The Answer for Question 5",
"question":"5. This is the Question?"
},
{
"answer":"The Answer for Question 3",
"question":"3. This is the Question?"
},
{
"answer":"The Answer for Question 8",
"question":"8. This is the Question?"
},
{
"answer":"The Answer for Question 4",
"question":"4. This is the Question?"
},
{
"answer":"The Answer for Question 6",
"question":"6. This is the Question?"
}
]
It will be serialized using JSON.Net to populate these classes:
public class WebinarQuestions {
public List<WebinarQuestion> questions { get; set; }
}
public class WebinarQuestion {
public string answer { get; set; }
public string question { get; set; }
}
I'd like the WebinarQuestions.questions to be in order. Is there a way to do this without iterating over the JSON?
I don't know why they come over in that order and don't really have any control over them.
questionfield to figure out what order they should be in, which is pretty ugly. Actually, on second thoughts, because they start with the number, so long as there are less than9you could just sort the strings, but that's pretty hacky.