title: JSON.parse returns string instead of object
body: <p>im writing a websocket client and i would like to receive messages as json strings. For this I need a login. And if the login isn't true i send a json string with nosuccess.
  JSON String:</p>
  
  <pre><code>{"action":"login","args":["nosuccess"]}
  </code></pre>
  
  <p>On the client I'm using this to get the string:</p>
  
  <pre><code>WebSocket socket = new WebSocket("ws://localhost:2555/api");
  
  socket.onmessage = function(evt) {
      console.log(evt.data);
      console.log(typeof(evt.data));
      onMessage(evt);
  }
  function onMessage(evt) {
  var data = JSON.parse(evt.data);
  var action = data.action;
  var args = data.args;
  console.log(data);
  console.log(typeof(data));
  console.log(action);
  console.log(args);
  </code></pre>
  
  <p>But the type of data is a string...
  But why?</p>
  
  <p>evt.data returns:</p>
  
  <pre><code> "{\"action\":\"login\",\"args\":[\"nosuccess\"]}"
  </code></pre>
  
  <p>data returns:</p>
  
  <pre><code> {"action":"login","args":["nosuccess"]}
  </code></pre>
  
  <p>The WebSocket server is a jetty Server which sends a string and a string array in json parsed in json with gson.toJson(class) Gson by Google. The Class is a class containing String action and String array args.</p>
  
  <p>Complete source code of websocket.js:</p>
  
  <pre><code>var socket;
  
  function openWebsocket(adress) {
      socket = new WebSocket(adress);
      socket.onopen = function(evt) {
          console.log("Socket opened [" + adress + "]");
      };
      socket.onclose = function(evt) {
          loadPage("login.html");
          console.log("Socket closed [" + evt.code + "]");
      }
      socket.onmessage = function(evt) {
          onMessage(evt);
      }
      socket.onerror = function(evt) {
          console.log("Socket couldn't connect [" + evt.message + "]");
          showMessage("fa-exclamation-circle", "Socket couldn't be established!", 1000);
      }
  }
  
  function onMessage(evt) {
      var data = JSON.parse(evt.data);
      var action = data.action;
      var args = data.args;
      console.log(data);
      console.log(typeof(data));
      console.log(action);
      console.log(args);
      $(".card-container h3").html(data);
  
      if(action == "login") {
          if(args[0] == "success") {
              loadPage("dashboard.htm");
              currentpage = "dashboard.htm";
              showMessage("fa-check", "Du wurdest erfolgreich eingeloggt", 2000);
          } else if(args[0] == "nosuccess") {
              loadPage("login.html");
              currentpage = "login.html";
              showMessage("fa-exclamation-circle", "Falscher Benutzername oder falsches Passwort", 2000);
          } else if(args[0] == "unauthenticated") {
              loadPage("login.html");
              currentpage = "login.html";
              showMessage("fa-exclamation-circle", "Login failure: not authenticated", 2000);
          }
      }
  
  }
  
  function sendMessage(json) {
      $(".card-container h3").html(JSON.stringify(json));
      console.log(JSON.stringify(json));
      socket.send(JSON.stringify(json));
  }
  </code></pre>
  
  <p>If I change this line:</p>
  
  <pre><code> var data = JSON.parse(evt.data);
  </code></pre>
  
  <p>to this:</p>
  
  <pre><code>var data = JSON.parse("{\"action\":\"login\",\"args\":[\"nosuccess\"]}");
  </code></pre>
  
  <p>Then it is a json object, but when I use evt.data then it is a string.
  If I change the line to this:</p>
  
  <pre><code>    var data = JSON.parse(JSON.parse(evt.data));
  </code></pre>
  
  <p>Then it works, but why, normally it should do it with only one JSON.parse, should it?</p>