title: Send array of object with Ajax and read it from nodejs server
body: <p>i'm developing a web application with javascript,jquery and nodejs. 
  I'm trying to read fields of the body of the client's request, that is composed by an array of objects and other fields. I'm able to read only the simply fileds and not the array of object. 
  Client side:</p>
  
  <pre><code> var week = [
  
      { day: 'Monday', start: startMonday, end: endMonday},
      { day: 'Tuesday', start: startTuesday, end: endTuesday},
      { day: 'Wednesday', start: startWednesday, end: endWednesday},
      { day: 'Thursday', start: startThursday, end: endThursday},
      { day: 'Friday', start: startFriday, end: endFriday},
  
  ]
  if (/^\s*$/.test(name) || /^\s*$/.test(professor) || /^\s*$/.test(startDate) 
  || /^\s*$/.test(endDate)  ){
  
      alert("You have to compile all fields");
  
  }
  
  else{
     // console.log(week);
      $.ajax({
          type: "POST",
          url: '/addNewCourse',
          data:  {name,professor,startDate,endDate,week},
  
  
        }).done(function(){
              showCourses();
        }); 
  }
  </code></pre>
  
  <p>Server side i read correctly name,professor,startDate,endDate while if i do var week = req.body.week, week is undefined. 
  Server side the code is:</p>
  
  <pre><code>app.post('/addNewCourse',function(req,res){
  
      console.log(req.body);
      var name =  req.body.name;
      var professor = req.body.professor;
      var startDate = req.body.startDate;
      var endDate = req.body.endDate;
      var week = req.body.week;
  });
  </code></pre>
  
  <p>I need a method to reconstruct the week array. I tried to use <code>JSON.parse(req.body)</code>, but i obtain the following error: </p>
  
  <blockquote>
    <p>TypeError: Cannot convert object to primitive value at JSON.parse (&lt; anonymous &gt;)</p>
  </blockquote>