title: node.js get data from array or object
body: <p>I'm trying to access a data from a function, I thought it was an array so i made the <code>JSON.parse()</code> in order to split the array objects into var objects, but it seems to not be a real array, so I don't know what it is. </p>
  
  <p><strong>This is the code:</strong></p>
  
  <pre><code>app.post('/', function(request, response)
  {
      console.log('POST OK');
      mongoose.connect('mongodb://localhost');
  
      var db = mongoose.connection;
  
      db.on('error', console.error.bind(console, 'connection error:'));
      db.once('open', function callback()
      {
          database.findByName(request.body.username.toLowerCase(), function(error, data)
          {
              if(error)
              {
                  response.render('index',
                  {
                      'Title': Title,
                      'result': 'Error, please try again later.'
                  });
              }
  
              if(data.length &gt; 0)
              {
                  console.log(JSON.stringify(data));
                  if(request.body.username == data.username &amp;&amp; request.body.password == data.password)
                  {
                      response.render('index',
                      {
                          'Title': Title,
                          'result': 'Log in success.'
                      });
                  }
  
                  else
                  {
                      response.render('index',
                      {
                          'Title': Title,
                          'result': 'username/password invalid.'
                      }); 
                  }
              }
  
              response.render('index',
              {
                  'Title': Title,
                  'result': 'Not found'
              });
          });
      }); 
  });
  </code></pre>
  
  <p>One of the <code>if</code> statements is not working because <code>data.object()</code> is undefined so I made the log of the data and I get :</p>
  
  <pre><code>[{"username":"maggns","password":"22542214","other data"}]
  </code></pre>
  
  <p>The JSON.parse is not working, it throws me an error. Any idea how to parse this data?</p>