Q:

Node.js body-parser won't parse input names with square brackets in json

I have a problem with Express body-parser in Node.js
I have inputs like this:
<input id="personEmail1" type="email" name="person[0][email]" placeholder="Email1" class="form-control">
<input id="personEmail2" type="email" name="person[1][email]" placeholder="Email2" class="form-control">

After when I submit my form I got this in my console.log:
{ 'person[0][email]': 'info@sss.sss', 'person[1][email]': 'info@ggg.ggg' }

But I want it to be parsed in json format:
{ person: [{email: 'info@sss.sss'}, {email: 'info@ggg.ggg'}] }

What I'm doing wrong?

A:

for express version 4.x when you need to manually install body-parser and multer, and you want to get nested properties from the post, e.g. data[test] in the form of req.body.data.test, you need to set:
app.use(bodyParser.urlencoded({ extended: true }));

