My app is Node.js using Express.
Sending this test data from my client using jQuery POST:
{
title: 'hello',
notes: [
{title: 'note 1'},
{title: 'note 2'}
]
}
And this is the result in my server code:
{ title: 'hello', notes: { '0': { title: 'note 1' }, '1': { title: 'note 2' } } }
I want to get the array of notes to insert into my DB as an Array. What am I missing?
As I can't add an answer myself for 8 hours (wtf?) BUT it does not really answer why Express.bodyParser does not parse JSON correctly
Ok I can get it to work by using:
JSON.stringify ( data )
on the client then server side using
JSON.parse( req.rawBody )
This does feel wrong and why does Express.bodyParser not parse JSON correctly?!
JSON.stringify
etc – Perception