title: Parse JSON serialised by CircularJSON
body: <p>I have a JSON object in my node.js code which contains circular references. To send this data to the browser, I used the NPM module <a href="https://github.com/WebReflection/circular-json" rel="nofollow">circular-json</a> to stringify the object and serialise the circular references:</p>
  
  <pre><code>var CircularJSON = require("circular-json");
  app.get("/api/entries", function(req, res){ 
    contentClient.entries({"content_type": "xxxxxxxxxxx"}, function(err, entries){
      if (err) throw err;
      res.send(CircularJSON.stringify(entries));
    });
  });
  </code></pre>
  
  <p>This works fine and sends serialised data through <code>res.send();</code>
  Now, in my frontend Angular code I need to make the circular references usable. One of the serialised fields in the object looks like this on the client side: <code>"~0~fields~twitter~1"</code></p>
  
  <p>I tried the following in the browser:</p>
  
  <ol>
  <li>Copied a version of <code>circular-json.js</code> to my frontend site</li>
  <li>Linked to the script in my <code>index.html</code> like so: <code>&lt;script src="/framework/lib/circular-json.js"&gt;&lt;/script&gt;</code></li>
  <li>Set the <code>CircularJson</code> variable like so: <code>var CircularJSON = window.CircularJSON;</code></li>
  <li><p>Parse the incoming JSON like so:</p>
  
  <p><code>$http.get("/api/entries").then(function(res){
    console.log(CircularJSON.parse(res.data[0]));
  });</code></p></li>
  </ol>
  
  <p>I get the following error:
  <code>SyntaxError: Unexpected token o</code></p>