我正在使用 Newtonsoft JSON 库,并且正在尝试反序列化 JSON。问题是,当我使用时,[JsonConverter(typeof(StringEnumConverter))]我收到此错误:Cannot apply attribute class 'JsonConverter' because it is abstract.
这是我的课程:
public class ActionRepository
{
[JsonConverter(typeof(StringEnumConverter))]
public enum AllowedActions
{
FINDWINDOW,
}
public enum AllowedParameters
{
WINDOWNAME,
}
}
public class Action
{
public AllowedActions Name { get; set; }
public List<Parameter> Parameters { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我在JsonConverter.
编辑:如果我导航到该类(在 VS 中按 Ctrl+单击),则 JsonConverter 类确实是抽象的。我使用 .NET for Windows Universal。