title: Express.js : POST data as KEY of a req.body object instead of VALUE of req.body?
body: <p>from the client I'm doing :</p>
  
  <pre><code>$.ajax({
          url: '/create',
          type: 'POST',
          data: JSON.stringify({
              theme: "somevalue",
              snippet: {
                  name: "somename",
                  content: "somevalue"
              }
          }), 
          complete: function (response)
          {
  
          }
      });
  </code></pre>
  
  <p>on the server ( <code>node.js/express.js</code> ) I'm doing :</p>
  
  <pre><code>var app = express();
  app.use(cookieParser());
  app.use(bodyParser.json());
  app.use(bodyParser.urlencoded({extended: true}));
  .......
  ... 
  app.post('/create', function (req, res)
  {
     var dataReceived = req.body;
  });
  </code></pre>
  
  <p>I expected the value of  <code>dataReceived</code> to be :</p>
  
  <pre><code>{
     "theme" : "somevalue",
     "snippet" : {
       "name": "somename",
       "content" : "somevalue"
     } 
  }
  </code></pre>
  
  <p>Instead the value of <code>dataReceived</code> was :</p>
  
  <pre><code>{ 
   '{"theme":"somevalue","snippet":"name":"somename","content":"somevalue"}}': '' 
  }
  </code></pre>
  
  <p>This is really weird and I can't find what I'm doing wrong. Any ideas?</p>
  
  <p>from the <a href="https://github.com/expressjs/body-parser" rel="noreferrer">BodyParser module documentation</a> :</p>
  
  <blockquote>
    <p>bodyParser.urlencoded(options)</p>
    
    <p>Returns middleware that only parses urlencoded bodies. This parser
    accepts only UTF-8 encoding of the body and supports automatic
    inflation of gzip and deflate encodings.</p>
    
    <p>A new body object containing the parsed data is populated on the
    request object after the middleware (i.e. req.body). This object will
    contain key-value pairs, where the value can be a string or array
    (when extended is false), or any type (when extended is true).</p>
  </blockquote>
  
  <p>Is this related to my problem ?</p>