Skip to content

[Authoring] Templating doesn't support JSON keys with whitespace #9171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
jvert opened this issue May 8, 2025 · 2 comments
Open

[Authoring] Templating doesn't support JSON keys with whitespace #9171

jvert opened this issue May 8, 2025 · 2 comments

Comments

@jvert
Copy link

jvert commented May 8, 2025

Target Application

Teams, Copilot

Application Operating System

Windows

Schema Version

1.4

Problem Description

Given this card

{
    "type": "AdaptiveCard",
    "body": [
        {
            "type": "TextBlock",
            "text": "Product ${product}"
        },
        {
            "type": "TextBlock",
            "text": "Price ${unit price}"
        }
    ],
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.6"
}

and this payload

{
    "product": "Widget",
    "unit price": "$42"
}

The card does not render at all in the designer. I could not find any documentation on the differences between property names as supported in the binding syntax vs. legal JSON key names. I tried a variety of escaping techniques with no success.

Expected Outcome

A way to bind to a JSON key that contains whitespace.

Actual Outcome

Card does not render in the designer
Value is rendered as "${unit price}" in Copilot

Card JSON

{
    "type": "AdaptiveCard",
    "body": [
        {
            "type": "TextBlock",
            "text": "Product ${product}"
        },
        {
            "type": "TextBlock",
            "text": "Price ${unit price}"
        }
    ],
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
    "version": "1.6"
}

Repro Steps

No response

@keshavk-msft
Copy link

Thank you for raising your issue. We will check this and will get back to you shortly.

@keshavk-msft
Copy link

Hi @jvert ,
Thank you for reporting this issue.

The behavior you're observing is due to a current limitation in the Adaptive Cards templating engine. Specifically, binding expressions do not support JSON keys that contain whitespace (e.g., "unit price"). As a result, expressions such as ${unit price} are not parsed correctly, which can lead to rendering failures or fallback behavior.

To resolve this, we recommend one of the following approaches:

Rename keys in your data model

  1. Update your payload to use keys without spaces:
    { "type": "TextBlock", "text": "Price ${unit_price}" }

  2. Preprocess your data before binding:
    If you do not control the data source, consider preprocessing the payload to convert keys with spaces into a more template-friendly format (e.g., replacing spaces with underscores) before rendering the card.

Thanks,
Keshav

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants