title: ServiceStack.Text serialize circular references
body: <p>I need to serialize an object graph like this:</p>
  
  <pre><code>public class A
  {
       public B Link1 {get;set;}
  }
  
  public class B
  {
       public A Link2 {get;set;}
  }
  </code></pre>
  
  <p>So that the json only gets two instances, but is deserialized correctly again. E.g. using a meta Id or something similiar.</p>
  
  <p>I know that there is a way in Json.NET as described here: <a href="http://note.harajuku-tech.org/serializing-circular-references-with-jsonnet" rel="nofollow">http://note.harajuku-tech.org/serializing-circular-references-with-jsonnet</a> with meta ids.</p>
  
  <p>Is there a similiar feature in <code>ServiceStack.Text</code> Json Serializer?</p>
  
  <p>Otherwise, is it possible to use Json.NET in <code>ServiceStack</code> and how?</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>To make it clear, i ask for instance references, not just the same type.
  An example of this may be:</p>
  
  <pre><code>[
      {
          "$id": "1",
          "BroId": 0,
          "Name": "John",
          "Bros": [
              {
                  "$id": "2",
                  "BroId": 0,
                  "Name": "Jared",
                  "Bros": [
                      {
                          "$ref": "1"
                      }
                  ]
              }
          ]
      },
      {
          "$ref": "2"
      }
  ]
  </code></pre>
  
  <p>There are only 2 objects "really" serialized, the rest is reused using the <code>$ref</code> property field. 
  Think of an object model having a collection of subitems. These subitems have a back-reference to their parent object. E.G. Customer/Order. One customer has multiple orders, each order has a reference to its customer. 
  Now think of what happens, if you serialize one customer.</p>
  
  <pre><code>Customer
   -&gt; Order
    -&gt; Customer
     -&gt; Order
      -&gt; ...
  </code></pre>
  
  <p>And you result in something similiar to this site's name. ;)</p>
  
  <p>I really like ServiceStack for its clearity, not to require <code>KnownTypeAttribute</code>s etc.</p>
  
  <p>I would love to keep it that clean, without to implement custom loader/object initializers in my business logic pocos.</p>