引用:
https://www.cjavapy.com/article/2513/
https://www.cnblogs.com/weihanli/p/11080531.html
https://www.cnblogs.com/Lulus/p/16968656.html
https://www.cjavapy.com/article/2513/
https://www.cnblogs.com/net-sky/p/16563025.html
public class DecimalConverter : JsonConverter
{
public DecimalConverter()
{
}
public override bool CanConvert(Type objectType)
{
return (objectType == typeof(decimal));
}
public override void WriteJson(JsonWriter writer, object value, JsonSerializer serializer)
{
decimal? dec = value as decimal?;
if (dec == null)
return;
writer.WriteValue((dec.Value).ToString("0.00"));
}
public override bool CanRead
{
get { return false; }
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
//do nothing
return existingValue;
}
}
标签:www,JsonConverter,return,自定义,JSON,https,override,com,public
From: https://www.cnblogs.com/yzpopulation/p/17308909.html