ExpressJS bodyParser: Array of objects
<p>I am building a form that can have a variable number of inputs (users can duplicate form elements). When I try to create an array of objects without the indices, object values are grouped together in an array, rather than grouped as an array of object. Is there a way to do this without specifying the index of the object?</p>

<p>This is my post data without indices:</p>

<pre><code>data[message][attachment][payload][elements][buttons][][title]="test 1"
data[message][attachment][payload][elements][buttons][][url]="http://www.com"
data[message][attachment][payload][elements][buttons][][type]="post"
data[message][attachment][payload][elements][buttons][][title]="test 2"
data[message][attachment][payload][elements][buttons][][url]="http://other.com"
data[message][attachment][payload][elements][buttons][][type]="get"
</code></pre>

<p>When I use console.log(req.body.data) in ExpressJS I see, which is not what I want:</p>

<pre><code>{
     "message": {
         "attachment": {
             "payload": {
                 "elements": [{
                     "buttons": [{
                         "title": ["test 1", "test 2"],
                         "url": ["http://www.com", "http://other.com"],
                         "type": ["post", "get"]
                     }]
                 }]
             }
         }
     }
 }
</code></pre>

<p>This is my post data with indices:</p>

<pre><code>data[message][attachment][payload][elements][buttons][0][title]="test 1"
data[message][attachment][payload][elements][buttons][0][url]="http://www.com"
data[message][attachment][payload][elements][buttons][0][type]="post"
data[message][attachment][payload][elements][buttons][1][title]="test 2"
data[message][attachment][payload][elements][buttons][1][url]="http://www.com"
data[message][attachment][payload][elements][buttons][1][type]="get"
</code></pre>

<p>When I use console.log(req.body.data) in ExpressJS I see:</p>

<pre><code>{
    "message": {
        "attachment": {
            "payload": {
                "elements": [{
                    "buttons": [{
                        "title": "test 1",
                        "url": "http://www.com",
                        "type": "post"
                    }, {
                        "title": "test 2",
                        "url": "http://other.com",
                        "type": "get"
                    }]
                }]
            }
        }
    }
}
</code></pre>

<p>Which is exactly what I'm after. Any help would be greatly appreciated!</p>