using System.Collections.Generic;
using System.ComponentModel;
using Newtonsoft.Json.Serialization;
class IncludeInstandardizedServerReportingContextAttribute : Attribute
public string Name1 {get; set;}
[IncludeInstandardizedServerReportingContext]
public string Address1 {get; set;}
[IncludeInstandardizedServerReportingContext]
public Employee Manager { get; set; }
public static void Main()
var settings = new JsonSerializerSettings() {
ContractResolver = new IncludeInstandardizedServerReportingContextAttributeResolver()
Console.WriteLine(JsonConvert.SerializeObject(p1, Formatting.Indented, settings));
class IncludeInstandardizedServerReportingContextAttributeResolver : DefaultContractResolver
PropertyDescriptorCollection props = null;
public IncludeInstandardizedServerReportingContextAttributeResolver() : base()
props = TypeDescriptor.GetProperties(typeof(Employee), new System.Attribute[] {new IncludeInstandardizedServerReportingContextAttribute()});
protected override JsonProperty CreateProperty(MemberInfo member, MemberSerialization memberSerialization)
JsonProperty property = base.CreateProperty(member, memberSerialization);
if (property.DeclaringType == typeof(Employee) && props.Find(property.PropertyName, false) == null) {
property.ShouldSerialize =