title: Strange JSON.parse() error in node.js
body: <p>I'm retrieving some stringifyed JSON via TCP in node.js an want to parse it. So my approach is similiar to this. I shortend and simplified it, so you don't have to know the surrounding logic.</p>
  
  <pre><code>socket.on("data", function(data) {
      console.log(data.toString());               // Shows the original stringifyed version
      console.log(JSON.parse(data.toString()));   // Doesn't work
  });
  </code></pre>
  
  <p>The complete (beautified) JSON is this. As you can see, there are no errors.</p>
  
  <pre><code>{
      "result": "success",
      "source": "chat",
      "success": {
          "message": "test",
          "time": 1331770513,
          "player": "silvinci"
      }
  }
  </code></pre>
  
  <p>But <code>JSON.parse(data.toString())</code> always throws me this dumb error:</p>
  
  <pre><code>{"result":"success","source":"console","success":{"time":1331762264,"line":"20
  ^
  SyntaxError: Unexpected token {
      at Object.parse (native)
      at Socket.&lt;anonymous&gt; (/home/node/api.js:152:35)    // irrelevant from here on
      at Socket.emit (events.js:67:17)
      at TCP.onread (net.js:347:14)
  </code></pre>
  
  <p>So I thougt: "What could be wrong with the JSON-String. Let's try it directly. Should not work." Surprise, Surprise! It worked. Why does it work when I directly enter the String?</p>