Using C#, .Net v4.0 - Given the following structure:
public interface IInterface {...}
public class MyClass : IInterface
{
public MyClass() {}
.
.
.
}
I do have parameterless constructor defined in the class.
Upon receiving a JSON object, I attempt to deserialize MyClass
and receive an error along the lines of:
no parameterless constructor defined for this object
var serializer = new JavaScriptSerializer(new SimpleTypeResolver());
var newObject = serializer.Deserialize(jsonObject, myClass.GetType());
I have also tried without the SimpletypeResolver()
I have seen a few posts that seem to hover around what I'm looking for, but not quite there - unless I'm missing something.
MyClass
implements an interface, no default constructor can be defined in an interface. Got it. So how can I deserialize MyClass
objects?