Ich habe eine Reihe von Radio-Button-Gruppen eingerichtet, um Antworten auf Fragen darzustellen.Parse Radio-Taste Antworten in Array (Express.js)
Im Format:
Was ist Ihre Lieblingsfarbe rot | Blau
Markup:
<input type="radio" name="Question_1" value="Red" id="Question_1_Red" />
<label for="Question_1_Red">Red</label>
<input type="radio" name="Question_1" value="Blue" id="Question_1_Blue" />
<label for="Question_1_Blue">Blue</label>
Ich bin Knoten mit (Express)
In req.body, erhalte ich die folgende zurück:
Question_1: 'Red', Question_2: 'Andere Antwort', Question_3: 'Eine andere Antwort'
Meine Frage ist, wie kann ich dies in ein Array legen, so kann ich es wie speichern:
[{QuestionID: 1, Antwort: "Red"}, { QuestionID: 2, Antwort: "Andere Antwort"}]