using System.Runtime.Serialization;
public static void Main()
var obj = new Organization { Address = new Address(), Subsidiary = new Organization() };
var json = JsonConvert.SerializeObject(obj, Formatting.Indented);
var addr = new Address();
json = JsonConvert.SerializeObject(addr, Formatting.Indented);
public class NoContextConverter : JsonConverter
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
var props = value.GetType().GetProperties()
props.RemoveAll(p => p.Name == "Context");
writer.WriteStartObject();
foreach (var prop in props)
writer.WritePropertyName(prop.Name);
serializer.Serialize(writer, prop.GetValue(value, null));
public override bool CanConvert(Type objectType)
return typeof(Thing).IsAssignableFrom(objectType);
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
throw new NotImplementedException();
[JsonConverter(typeof(NoContextConverter))]
public string Context { get { return "http://schema.org"; } }
public class Organization : Thing
public Address Address { get; set; }
public Organization Subsidiary { get; set; }
public class Address : Thing