title: NodeJS: Very large JSON from remote resource parsing
body: <p>I have a very large JSON file(150k lines, ~3mb) coming from an external resource,
  I wonder what is the best approach to work with it under NodeJS application.</p>
  
  <p>My strategy at the moment was get it with an ajax call, parse it and store it in cache:</p>
  
  <pre><code>var options = {
  host: url,
  port: port,
  path: '/file.json',
  headers: {'Authorization': 'Basic ' + new Buffer(username + ':' +password).toString('base64')
      }
  };
  
  http.get(options, function (res) {
      var body = '';
  
      res.on('data', function (chunk) {
          body += chunk;
      });
  
      res.on('end', function () {
          var JsonAsObject = JSON.parse(body);
          StatisticsCache.set("Json", JsonAsObject, function(err, success) {
             console.log("err is " + err + "success is " + success);
          });
      })
  }).on('error', function (e) {
      console.log("Got error: ", e);
  });
  </code></pre>
  
  <p>But what I exprience is that this line:</p>
  
  <pre><code>var JsonAsObject = JSON.parse(body);
  </code></pre>
  
  <p>Takes forever (3 minutes) and even then the object is not accessible in debug.</p>
  
  <p>In the end my goal is to be able and process it's information,</p>
  
  <p>Thanks</p>