I am using Newtonsoft.Json to deserialize the output from my web service for an object. It worked fine until I added a property Bitmapto my class (named User) to store the avatar.
Webservice returns this property as a Base64 string, which is as expected. The problem is that when I try to convert JSON from WS to List<User>, a JsonSerializationExceptionis called in this block of code:
response.Content.ReadAsStringAsync().Proceed(
(readTask) =>
{
var json = ((Task<string>)readTask).Result;
var result = JsonConvert.DeserializeObject<T>(json);
});
Exit exception:
Error converting value "System.Drawing.Bitmap" to type 'System.Drawing.Bitmap'. Path '[2].Avatar
and looking at an internal exception:
{"Could not cast or convert from System.String to System.Drawing.Bitmap."}
It is clear that it does not parse the Base64 string, but it is not clear why.
Any ideas / workarounds?
, Convert.FromBase64String . , , .
, JSON.
?
2
: JSON webservice ( ). , , . - "System.Drawing.Bitmap" base64. , JsonSerializationException.
, , , - byte [].