title: Ignore Base Class Properties in Json.NET Serialization
body: <p>I have the following class structure:</p>
  <pre><code>[JsonObject]
  public class Polygon : IEnumerable&lt;Point&gt;
  {
      public List&lt;Point&gt; Vertices { get; set; }
      public AxisAlignedRectangle Envelope { get; set; }
  }
  
  public class AxisAlignedRectangle : Polygon {
      public double Left { get; set; }
      ...
  }
  </code></pre>
  <p>I am serializing the <code>Polygon</code> class, but when I do, I get a <code>JsonSerializationException</code>, with the message</p>
  <blockquote>
  <p>Self referencing loop detected for property 'Envelope' with type 'MyNamespace.AxisAlignedRectangle'.</p>
  </blockquote>
  <p>If I add <code>[JsonObject(IsReference = true)]</code> (<a href="https://stackoverflow.com/a/18223985/960115">as described here</a>) to AxisAlignedRectangle, the code runs fine, but I get an auto-assigned $id field in each instance of AxisAlignedRectangle, and a $ref field when that instance is re-referenced.  For example, when I serialize a polygon, I get:</p>
  <pre><code>{
      Vertices: [ ... ],
      Envelope: {
          $id: '1',
          Left: -5,
          ...
          Vertices: [ ... ],
          Envelope: {
              $ref: '1'
          }
      }
  }
  </code></pre>
  <p>My desire is to remove the Polygon properties entirely when I serialize an AxisAlignedRectangle.  I tried adding a <code>DataContractAttribute</code> to the AxisAlignedRectangle class (along with appropriate <code>DataMemberAttribute</code> attributes), but all the properties of Polygon were still being serialized.  This was unexpected, since there is an example in the <a href="http://www.newtonsoft.com/json/help/html/DataContractAndDataMember.htm" rel="nofollow noreferrer">Json.NET documentation</a> that appears to indicate such an approach should work.</p>
  <p>Does anyone know a way to explicitly remove (most importantly) the Envelope property from the resulting Json.NET serialization, when the type being serialized is AxisAlignedRectangle?  Thanks.</p>