JSFiddle - React, Tailwind, and code Playground

HTML

<h2>Form</h2>
<form action="" method="post">
Which city is in Great Britain?<br/>
<input type="hidden" name="first" value="1"/>
London:<input type="radio" name="first" data-questionid="1" value="11"/><br/>
New York:<input type="radio" name="first" data-questionid="1" value="12"/><br/>
Which city is in USA?<br/>
<input type="hidden" name="second" value="2"/>
Washington:<input type="radio" name="second" data-questionid="2" value="13"/><br/>
Tokio:<input type="radio" name="second" data-questionid="2" value="14"/><br/>
<p><input type="submit" /></p>
</form>
<h2>JSON</h2>
<pre id="result">
</pre>

CSS

form {
    line-height: 2em;
}
p {
    margin: 5px 0;
}
h2 {
    margin: 10px 0;
    font-size: 1.2em;
    font-weight: bold
}
#result {
    margin: 10px;
    background: #eee;
    padding: 10px;
    height: 40px;
    overflow: auto;
}

JavaScript

$(function() {
    $('form').submit(function() {
        var voted_questions = [];
        var answers = [];

        $('input[type="radio"]:checked').each(function(){
            voted_questions.push($(this).data('questionid'));
            answers.push({'question':$(this).data('questionid'), 'options':this.value});
        });

        var data = {
            'voted_questions': voted_questions,
            'answers': answers
        };

        $('#result').text(JSON.stringify(data));
        return false;
    });
    

});