microsoft/AdaptiveCards

[Rendering] .NET Templating 2.0.0 - 2.0.3 Expand incorrectly when passed a JToken

justin-mellor opened this issue · 0 comments

Target Platforms

Other

SDK Version

2.0.3

Application Name

Bot Framework

Problem Description

If you call Expand with a Newtonsoft.Json JToken for the data, version 1.5.0 used to expand it correctly. With 2.0.0 and above the expansion goes to an empty array instead of the string property

So with 1.5.0 you end up with
"text": "This is a title"

with 2.0.0 and above you end up with
"text": []

Screenshots

No response

Card JSON

{
    "type": "AdaptiveCard",
    "body": [
        {
            "type": "TextBlock",
            "size": "Medium",
            "weight": "Bolder",
            "text": "${title}"
        }
    ],
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.6"
}

Sample Code Language

C#

Sample Code

var templateJson = """
    {
        "type": "AdaptiveCard",
        "body": [
            {
                "type": "TextBlock",
                "size": "Medium",
                "weight": "Bolder",
                "text": "${title}"
            }
        ],
        "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
        "version": "1.6"
    }
    """;

var dataJson = """
    {
        "title": "This is a title",
        "description": "Something else"
    }
    """;

var template = new AdaptiveCards.Templating.AdaptiveCardTemplate(templateJson);

var data = Newtonsoft.Json.JsonConvert.DeserializeObject<Newtonsoft.Json.Linq.JToken>(dataJson);

var card = template.Expand(data);