title: Include Class name as part of the serialization in JSON C#
body: <p>I have a specific situation where I need to include the class name as property in JSON when classes are serialized. The tricky parts is I need to do this dynamically. I can't just create an anonymous class before calling serialization. </p>
  
  <p>I have decorated my class with a custom attribute as below:</p>
  
  <pre><code> [OntologyArea("con", " http://someurl/area/DomicileAddress")]
      public class DomicileAddress : IContactPoint
      {
  
          [JsonProperty(PropertyName = "con:hasAddressPoint")]
          public IAddressPoint AddressPoint
          {
              get; set;
          }
      }
  </code></pre>
  
  <p>In the above example the <code>OntologyArea</code> attribute should be read and included as a Property. The propery name should be the first argument of <code>OntologyArea</code> + the class name (i.e con:DomicileAddress) and the value should be the concrete class of <code>IAddressPoint</code>. </p>
  
  <p>The tricky part is that the concrete class of IAddressPoint might need to do the same as shown here:</p>
  
  <pre><code>[OntologyArea("geo", "http://someurl.net/geolocation")]
      public class StreetAddress : IAddressPoint
      {
          [JsonProperty("geo:hasStartingStreetNumber")]
          public string StartingStreetNumber
          {
              get; set;
          }
      }
  </code></pre>
  
  <p>an example of JSON:</p>
  
  <pre><code>"con:DomicileAddress" : {
      "con:hasAddressPoint" : {
          "geo:StreetAddress" : {
              "geo:hasEndingStreetNumber" : ""
          }
      }
  }
  </code></pre>
  
  <p>So if any object does have a <code>OntologyArea</code> attribute I need to add a parent level. If it does not contain this attribute normal serilization should continue. </p>
  
  <p>Please let me know If I need to explain more. </p>