title: Avoid repetition in JSON
body: <p>When you have a javascript object tree where some branches are repeated, is there a to tool which could output it withouth the repetition?</p>
  
  <p>example:</p>
  
  <p>situation as is:</p>
  
  <pre><code>var a = new MyHugeObject();
  var b = "Hello world!";
  var c = 42;
  var result = { main: a, all: [a, b, c] };
  console.log(JSON.stringify(result));
  </code></pre>
  
  <p>where output would contain the whole JSON of <code>a</code> twice</p>
  
  <pre><code>{main:/* lot of json removed*/,all:[/* same lot of json removed*/,"Hello world!",42]}
  </code></pre>
  
  <p>sitution to be:</p>
  
  <pre><code>var a = new MyHugeObject();
  var b = "Hello world!";
  var c = 42;
  var result = { main: a, all: [a, b, c] };
  console.log(someMagic(result));
  </code></pre>
  
  <p>where output would contain the whole JSON of <code>a</code></p>
  
  <pre><code>{main:/* lot of json removed*/,all:reference-to-main,"Hello world!",42]}
  </code></pre>
  
  <p>I took a glimpse at falcor's json graph, but I didn't dig very deep and was left with the impression that it wouldn't eventually just let me convert an existing object to an optimized json.</p>