title: JSON in node.js
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/11911438/json-array-in-node-js">JSON array in Node.js</a>  </p>
  </blockquote>
  
  
  
  <p>Im kinda new to node.js and Im working on only the server side to answer POST from the client side. What i need to do is when a POST request is made at location '/sort' with parameter 'theArray', sort the array removing all non-string values and return the resulting value as JSON. theArray parameter will be a stringified JSON Array.
  I have tried this code here:</p>
  
  <pre><code>case '/sort':
          if (req.method == 'POST') {
              res.writeHead(200,{
                  'Content-Type': 'application/json'
              });
              var fullArr = "";
                  req.on('data', function(chunk) {
                      fullArr += chunk;
                      });
                  req.on('end', function() {
                              var query = JSON.parse(fullArr);
                              var arr = "";
                              var par = query.theArray;
                              arr += par;
                      console.log(arr); 
  
                                  function censor(key, value) {
                                      if (typeof value == "string") {
                                              return value;
                                          } 
                                          return undefined;
                                          }
                          var jsonString = JSON.stringify(arr, censor);
                          console.log(jsonString);
                  });         
                      res.end();
  
  
          };
  </code></pre>
  
  <p>break;</p>
  
  <p>But it just returns the same thing? I have also tried replacing the qs.parse with the JSON.parse and it just returned undefined? Can someone please help! Thanks </p>