我在使用JSON序列化JavaScriptSerializer的System.Drawing.Color,但是當我嘗試反序列化,它返回的所有值0JavaScriptSerializer不是反序列化System.Drawing.Color。如何反序列化Color對象?
樣品JSON是如下Color對象。
{
"A":255,
"B":0,
"G":165,
"IsEmpty":false,
"IsKnownColor":true,
"IsNamedColor":true,
"IsSystemColor":false,
"Name":"Orange",
"R":255
}
下面是反序列化對象的外觀樣式的截圖。
然後我試圖使用JSON.net(newtonsoft.json)庫。它給了我下面的錯誤。
Cannot deserialize the current JSON object (e.g. {"name":"value"}) into type 'System.Drawing.Color' because the type requires a JSON string value to deserialize correctly.
有deserialzing JSON的任何方式上色object.i發現this類似的問題,沒有任何的answere。
我已經在5月的地方它不是寫'System.Drawing.ColorTranslator.ToHtml可行使用Color對象類的實例通'或'ColorTranslator.FromHtml'。 –