首页 > 代码库 > Json.net 同过 JsonConverter 调整导出值(未完成)

Json.net 同过 JsonConverter 调整导出值(未完成)

public class TimeSpanConverter : JsonConverter    {        public override bool CanConvert(Type objectType)        {            return objectType == typeof(TimeSpan);        }            public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)        {            writer.WriteStartObject();            writer.WritePropertyName("$type");            writer.WriteValue(value.GetType().FullName);            writer.WritePropertyName("$value");            writer.WriteValue(value);            writer.WriteEndObject();        }            public override object ReadJson(JsonReader reader, Type type, object value, JsonSerializer serializer)        {            return value;        }       }

stackoverflow在找一下