No parameterless constructor defined for type of 'System.String' during JSON deserialization

Parameterless constructors need for any kind of deserialization. Imagine that you are implementing a deserializer. You need to:

  1. Get a type of object from the input stream (in this case it's string)
  2. Instantiate the object. You have no way to do that if there is no default constructor.
  3. Read the properties/value from stream
  4. Assign the values from the stream to the object created on step 2.

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);