title: How to load JSON via get into variable in CasperJS script
body: <p>I'm using the following code to load some JSON data into a variable in my casperJS script:</p>
  
  <pre><code>var casper = require("casper").create({
      verbose: true,
      logLevel: 'debug',
      pageSettings: {
          userName: 'dev',
          password: 'devpass',
      } 
  });
  var baseUrl = 'http://mysite.com/';
  
  casper.start().then(function() {
      this.open(baseUrl + 'JSON-stuff', {
          method: 'get',
          headers: {
              'Accept': 'application/json'
          }
      });
  });
  
  casper.run(function() {
      var journalJson = JSON.parse(this.getPageContent());
      require('utils').dump(journalJson);  //this returns my json stuff as expected
      this.exit();
  });
  </code></pre>
  
  <p>This works like I want - I have the journalJson object that I need to do my processing. However, I'm not sure how to continue with my testing. Other functions added to casper.run() do not execute as expected... for instance, if I change the casper run function to:</p>
  
  <pre><code>casper.run(function() {
      var journalJson = JSON.parse(this.getPageContent());
      require('utils').dump(journalJson);
      this.open(baseUrl).then(function () {
          this.assertExists('#header');
      });
      this.exit();
  });
  </code></pre>
  
  <p>then phantomjs logs that the url is requested, but the test is never run. </p>
  
  <p>My question:  How can I access JSON via get, and then use it to perform tests? I think that I'm missing something here...</p>