Я пытаюсь вывести файл JSON. Я использую netcoreapp3.1 вместе с Newtonsoft. Json NuGet. Вот мой код, в который я ввожу всю информацию:
private BlockWrapper GetBlock()
{
var blockWrapper = new BlockWrapper
{
blocks = new List<IntBlock>
{
new SectionBlockBlock
{
text = new TextBlock
{
type = "mrkdwn",
text = "Hello! I am Multiuse Kat. How can I help you ?"
}
},
new ActionsBlockBlock
{
elements = new ElementBlock[]
{
new ElementBlock
{
type = "button",
text = new TextBlock
{
type = "plain_text",
text = "Help"
},
style = "primary",
value = "click_me_123"
}
}
},
}
};
return blockWrapper;
}
Мои модели выглядят так. Обратите внимание, что я использую интерфейс с IntBlock:
public class BlockWrapper
{
public List<IntBlock> blocks { get; set; }
}
public class SectionBlockBlock : IntBlock
{
public string type { get; } = "section";
public string blockId { get; set; }
public TextBlock text { get; set; }
}
public class ActionsBlockBlock : IntBlock
{
public string type { get; } = "actions";
public string blockId { get; set; }
public ElementBlock[] elements { get; set; }
}
public class TextBlock
{
public string type { get; set; }
public string text { get; set; }
public bool? emoji { get; set; }
}
public class ElementBlock
{
public string type { get; set; }
public string action_id { get; set; }
public TextBlock text { get; set; }
public string value { get; set; }
public string style { get; set; }
}
public interface IntBlock { }
Когда я возвращаю новый JsonResult (GetBlock ()); Я вывожу это:
Я предполагаю, что это как-то связано с интерфейсом IntBlock. Может кто-нибудь сказать мне, как это исправить? Спасибо!