我正在使用枚举制作列表字典
这是我的枚举
class IntruderPayloadGenerator implements IIntruderPayloadGenerator
{
...
}
class IntruderPayloadGeneratorFactory implements IIntruderPayloadGeneratorFactory
{
@Override
public IIntruderPayloadGenerator createNewInstance(IIntruderAttack attack)
{
// return a new IIntruderPayloadGenerator to generate payloads for this attack
return new IntruderPayloadGenerator();
}
...
}
callbacks.registerIntruderPayloadGeneratorFactory(IntruderPayloadGeneratorFactory());
这是我的JSON
public enum EmailStatus
{
[Description("Email Draft")]
Draft = 1,
[Description("Email Sent")]
Send= 2,
[Description("Email Deleted")]
Delete= 3,
}
Json结果值为:
[HttpGet("getEmailStatus")]
public IActionResult GetStatusList()
{
var statusList = typeof(EmailStatus).ToListDictionary();
return Json(statusList);
}
我想返回说明而不是文本,这是我想要得到的结果:
{ value = 1, text = "Draft" },
{ value = 2, text = "Send" },
{ value = 3, text = "Delete" }