.NET Libraries for card creation

As we described in the Getting Started, an adaptive card is nothing more than a serialized JSON object of a card object model. To make it easy to manipulate the object model, we defined libraries which define a strongly-typed class hierarchy that makes it easy to serialize/deserialize JSON.

You can use any tooling that you want to create the adaptive card JSON.

.NET

The AdaptiveCards nuget package defines a class hierachy for working with adaptive cards in .NET

To install

Install-Package AdaptiveCards 

Example: create

using AdaptiveCards;
// ....

var card = new AdaptiveCard();

card.Body.Add(new TextBlock() 
{
    Text = "Hello",
    Size = TextSize.ExtraLarge,
    Color = TextColor.Attention
});

card.Body.Add(new Image() 
{
    Url = "http://someUrl.com/example.png"
});

Example: Parse from JSON

AdaptiveCardParseResult result = AdaptiveCard.FromJson(json);

if (result.Card != null)
{
    // Get card from result
    AdaptiveCard card = result.Card;
}
else
{
    // Failed parsing
}

Example: Export to JSON using JSON.NET

var json = JsonConvert.SerializeObject(card);