我正在try 建立一个阅读器,它将从各种网站(比如信息抓取)接收JSON对象,并将它们转换为C#对象.我目前正在使用JSON.NET进行反序列化过程.我遇到的问题是,它不知道如何处理类中的接口级属性.这是自然现象:
public IThingy Thing
Will produce the error:
无法创建I类型的实例.类型是接口或抽象类,无法实例化.
It is relatively important to have it be an IThingy as opposed to a Thingy since the code I am working on is considered sensitive and unit testing is highly important. Mocking of objects for atomic test scripts is not possible with fully-fledged objects like Thingy. They must be an interface.
我研究JSON.NET文档已经有一段时间了,我在这个站点上可以找到的与此相关的问题都是一年多前的.有什么帮助吗?
另外,如果有必要的话,我的应用程序是用英文写的.NET 4.0.