title: JSON encoding a string with the # and other special characters
body: <p>I have the following client side javascript code.</p>
  
  <pre><code>    &lt;html&gt;
      &lt;script type="text/javascript" src="js/jquery.min.js"&gt;&lt;/script&gt;
      &lt;script&gt;
  
      $(document).ready(function() {
          //var parameters = "a=" + JSON.stringify({ Code: "xyyyzz"}); 
          var parameters = "a=" + JSON.stringify({ Code: "x#yyy#zz"}); 
          alert(parameters);
  
          $.getJSON('http://localhost:8080', parameters)
          .done(function(str){
              alert("success");
              })
          .fail(function(e) {
              alert("failure");
              });
  
          });
  &lt;/script&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>and the following server side node.js code</p>
  
  <pre><code>var http = require('http');
  var URL = require('url');
  var queryString = require( "querystring" );
  
  handler = function(req, res) {
                  url = URL.parse(req.url);
                  var queryObj = queryString.parse( url.query );
                  var obj = JSON.parse( queryObj.a );
                  console.log( obj.Code);
  };
  
  host = '127.0.0.1';
  port = 8080;
  http.createServer(handler).listen(port, host);
  console.log('Server running at http://' + host + ':' + port + '/');
  </code></pre>
  
  <p>Now, if I load the .html file, the JSON call is made from the javascript. However, the parameter is not passed in full. It is passed only until the first # character and so causes the nodejs server to crash on the parse function. Now if I uncomment the previous line in the .js where a string without the # is passed, the nodejs server can succesfully parse the parameters.</p>
  
  <p>So my question is, Is JSON incapable of encoding special characters like # in a string ? Or is this a bug ? Or do I need to add anything else to fix this so that x#yyy#zz is passed as a whole string to the nodejs server ?</p>