JSON.Net Deserialize MailAddress
I have an object that contains a property called Email which is of type
System.Net.Mail.MailAddress. I am able to serialize my object with
JSON.Net and store it in the database. However, I'm unable to successfully
deserialize my object. The error message I get is:
Unable to find a constructor to use for type System.Net.Mail.MailAddress.
A class should either have a default constructor, one constructor with
arguments or a constructor marked with the JsonConstructor attribute. Path
'Item1.Email.DisplayName'.
I understand that MailAddress does not have a default constructor and that
is why I'm getting this error. My question is, is there any way around
this without converting the property type? I see there are custom
converters, but I haven't had any luck getting JSON.Net to successfully
deserialize this one property.
Thanks in advance for any pointers you can provide.
No comments:
Post a Comment