This seems like it should be so easy, but I am getting an exception when I try to deserialize some straightforward JSON into a managed type. The exception is:
Parameterless constructors need for any kind of deserialization. Imagine that you are implementing a deserializer. You need to:
I had the same issue and this was what fixed the issue.
Cheers!
//Deserializing Json object from string
DataContractJsonSerializer jsonObjectPersonInfo =
new DataContractJsonSerializer(typeof(PersonModel));
MemoryStream stream =
new MemoryStream(Encoding.UTF8.GetBytes(userInfo));
PersonModel personInfoModel =
(PersonModel)jsonObjectPersonInfo.ReadObject(stream);