title: Unexpected end of json input in Node.js
body: <p>I have Json data which I receive it as post data in my node.js server.</p>
  
  <p>But the problem is, its not able to parse the string I sent.Here is my node.js server code. </p>
  
  <pre><code>res.header("Access-Control-Allow-Origin", "*");
    req.on('data',function(data)
    {
      var done=false;
      console.log(data);
      var schema;
  
      schema=JSON.parse(data);
     }
  </code></pre>
  
  <p>Here I get the error when I parse the json data(data).</p>
  
  <pre><code>undefined:776
  
  
  
  SyntaxError: Unexpected end of JSON input
      at JSON.parse (&lt;anonymous&gt;)
      at IncomingMessage.&lt;anonymous&gt; (/Users/as6/Documents/test/server.js:206:17)
      at emitOne (events.js:115:13)
      at IncomingMessage.emit (events.js:210:7)
      at IncomingMessage.Readable.read (_stream_readable.js:462:10)
      at flow (_stream_readable.js:833:34)
      at resume_ (_stream_readable.js:815:3)
      at _combinedTickCallback (internal/process/next_tick.js:102:11)
      at process._tickCallback (internal/process/next_tick.js:161:9)
  </code></pre>
  
  <p>I verified JSON data using JSONLint for syntax errors.But it was absolutely fine. I dont know what's wrong and how to correct it.</p>