I want to change the default serializer in Newtonsoft.Json
for System.Drawing.Color
. Instead of the default string value I would like to fire this method:
public string ToHtml(Color c)
=> $"rgba({c.R},{c.G},{c.B},{c.A / 255f})";
Every time an object of type Color
is to be resolved. This is the format to be consumed by CSS.
What is an elegant, yet simple way to accomplish this?
EDIT
Here is an example json I want to create:
{
"color": "rgba(80,80,80,0.5)"
}