microsoft / microsoft/AdaptiveCards
[Rendering] Adaptive card templating is not working with an array element
Nobody has claimed this yet.
- Dominant language
- C#
- Stars
- 2k
- Forks
- 595
- Avg merge
- 1d 19h
- Merged PRs (30d)
- 1
Description
Target Platforms
Other
SDK Version
1.2.1 and 1.2.2
Application Name
Microsoft search
Problem Description
Expected behavior which works in Designer (using the js templating library):
Sample input:

Expected output:

Issue:
But the dot-net templating library is unable to parse the array element (ex: names) inside a string. It doesn't have any escape characters for the array element, causing an invalid JSON object to be outputted. This results in a rendering issue.
Screenshots
No response
Card JSON
Sample JSON:
{
"type": "AdaptiveCard",
"body": [
{
"type": "TextBlock",
"size": "Medium",
"weight": "Bolder",
"text": "Names: ${names}"
}
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"version": "1.5"
}
Sample data:
{
"names": ["Name1", "Name2", "Name3"]
}
Sample Code Language
C#
Sample Code
string jsonTemplate = @"{
""type"": ""AdaptiveCard"",
""body"": [
{
""type"": ""TextBlock"",
""size"": ""Medium"",
""weight"": ""Bolder"",
""text"": ""Names: ${names}""
}
],
""$schema"": ""http://adaptivecards.io/schemas/adaptive-card.json"",
""version"": ""1.5""
}";
var data = @"{
""names"": [""Name1"", ""Name2"", ""Name3""]
}";
var jsonData = JObject.Parse(data);
AdaptiveCardTemplate template = new AdaptiveCardTemplate(jsonTemplate);
var result = template.Expand(jsonData);
Output result = "{\"type\":\"AdaptiveCard\",\"body\":[{\"type\":\"TextBlock\",\"size\":\"Medium\",\"weight\":\"Bolder\",\"text\":\"Names: [\"Name1\",\"Name2\",\"Name3\"]\"}],\"$schema\":\"http://adaptivecards.io/schemas/adaptive-card.json\",\"version\":\"1.5\"}"
JObject.Parse(result); // -> **Throws exception**
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the AdaptiveCardTemplate constructor and Expand call shown in the sample, then trace how the ${names} value is inserted into the TextBlock text. Reproduce the case with the supplied card and data, and verify that the expanded result remains valid JSON when parsed with JObject.Parse while preserving the array values.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- csharp
- Domain
- backend
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100