自适应卡片在尝试制作 table 时未显示所有键和值

Adaptive cards not showing all keys and values when trying to make a table

最近工作中的一个应用需要学习自适应卡片,想代表一个table。我遇到的问题是,当我将样本数据置于预览模式时,它的所有键和值都没有显示在设计器站点上。我已经研究了一段时间,但找不到任何语法错误。我想知道我是否有太多列无法正确呈现,但我不确定。

卡片模板:

{
    "type": "AdaptiveCard",
    "version": "1.0",
    "body": [
        {
            "type": "ColumnSet",
            "columns": [
                {
                    "type": "Column",
                    "width": "stretch"
                },
                {
                    "type": "Column",
                    "width": "stretch",
                    "items": [
                        {
                            "type": "TextBlock",
                            "text": "100G",
                            "id": "100Gtxt",
                            "horizontalAlignment": "Center",
                            "weight": "Bolder"
                        }
                    ]
                },
                {
                    "type": "Column",
                    "width": "stretch",
                    "items": [
                        {
                            "type": "TextBlock",
                            "text": "FPW",
                            "weight": "Bolder",
                            "id": "FPWtxt",
                            "horizontalAlignment": "Center"
                        }
                    ]
                },
                {
                    "type": "Column",
                    "width": "stretch",
                    "items": [
                        {
                            "type": "TextBlock",
                            "text": "Serving Size",
                            "id": "ServingSizetxt",
                            "horizontalAlignment": "Center",
                            "weight": "Bolder"
                        }
                    ]
                }
            ]
        },
        {
            "type": "ColumnSet",
            "columns": [
                {
                    "type": "Column",
                    "width": "stretch",
                    "items": [
                        {
                            "type": "FactSet",
                            "facts": [
                                {
                                    "$data": "{propertiesNutritional}",
                                    "title": "{key}",
                                    "value": "{value}"
                                }
                            ],
                            "id": "NutritionalFact",
                            "separator": true,
                            "spacing": "None"
                        }
                    ]
                },
                {
                    "type": "Column",
                    "width": "stretch",
                    "items": [
                        {
                            "type": "FactSet",
                            "facts": [
                                {
                                    "$data": "{propertiesUom}",
                                    "title": "{key}",
                                    "value": "{value}"
                                }
                            ],
                            "id": "UomFact",
                            "separator": true,
                            "spacing": "None"
                        }
                    ]
                },
                {
                    "type": "Column",
                    "width": "stretch",
                    "items": [
                        {
                            "type": "FactSet",
                            "facts": [
                                {
                                    "$data": "{propertiesCurrent1}",
                                    "title": "{key}",
                                    "value": "{value}"
                                }
                            ],
                            "id": "CurrentFact1",
                            "separator": true,
                            "spacing": "None"
                        }
                    ]
                },
                {
                    "type": "Column",
                    "width": "stretch",
                    "items": [
                        {
                            "type": "FactSet",
                            "facts": [
                                {
                                    "$data": "{propertiesNew1}",
                                    "title": "{key}",
                                    "value": "{value}"
                                }
                            ],
                            "id": "NewFact1",
                            "spacing": "None",
                            "separator": true
                        }
                    ]
                },
                {
                    "type": "Column",
                    "width": "stretch",
                    "items": [
                        {
                            "type": "FactSet",
                            "facts": [
                                {
                                    "$data": "{propertiesCurrent2}",
                                    "title": "{key}",
                                    "value": "{value}"
                                }
                            ],
                            "id": "CurrentFact2",
                            "separator": true,
                            "spacing": "None"
                        }
                    ]
                },
                {
                    "type": "Column",
                    "width": "stretch",
                    "items": [
                        {
                            "type": "FactSet",
                            "facts": [
                                {
                                    "$data": "{propertiesNew2}",
                                    "title": "{key}",
                                    "value": "{value}"
                                }
                            ],
                            "id": "NewFact2",
                            "separator": true,
                            "spacing": "None"
                        }
                    ]
                },
                {
                    "type": "Column",
                    "width": "stretch",
                    "items": [
                        {
                            "type": "FactSet",
                            "facts": [
                                {
                                    "$data": "{propertiesCurrent3}",
                                    "title": "{key}",
                                    "value": "{value}"
                                }
                            ],
                            "id": "CurrentFact3",
                            "separator": true,
                            "spacing": "None"
                        }
                    ]
                },
                {
                    "type": "Column",
                    "width": "stretch",
                    "items": [
                        {
                            "type": "FactSet",
                            "facts": [
                                {
                                    "$data": "{propertiesNew3}",
                                    "title": "{key}",
                                    "value": "{value}"
                                }
                            ],
                            "id": "NewFact3",
                            "spacing": "None",
                            "separator": true
                        }
                    ]
                }
            ]
        }
    ],
    "$schema": "http://adaptivecards.io/schemas/adaptive-card.json"
}

示例数据:

{
  "propertiesNutritional": [
    {
      "key": "Nutritional",
      "value": "Calories"
    }
  ],
  "propertiesUom": [
    {
      "key": "UOM",
      "value": "Calories"
    }
  ],
  "propertiesCurrent1": [
    {
      "key": "Current",
      "value": "Number"

    }
  ],
  "propertiesNew1": [
    {
      "key": "New",
      "value": "Number"
    }
  ],
  "propertiesCurrent2": [
    {
      "key": "Current",
      "value": "Number"

    }
  ],
  "propertiesNew2": [
    {
      "key": "New",
      "value": "Number"
    }
  ],
  "propertiesCurrent3": [
    {
      "key": "Current",
      "value": "Number"

    }
  ],
  "propertiesNew3": [
    {
      "key": "New",
      "value": "Number"
    }
  ]
}

是的,无论出于何种原因(认为它已经作为一个问题添加),您的 属性 名称中不能包含数字。例如,将 propertiesCurrent3 更改为 propertiesCurrentC 就可以了。

试试这个:

{
"type": "AdaptiveCard",
"version": "1.0",
"body": [
    {
        "type": "ColumnSet",
        "columns": [
            {
                "type": "Column",
                "width": "stretch"
            },
            {
                "type": "Column",
                "width": "stretch",
                "items": [
                    {
                        "type": "TextBlock",
                        "text": "100G",
                        "id": "100Gtxt",
                        "horizontalAlignment": "Center",
                        "weight": "Bolder"
                    }
                ]
            },
            {
                "type": "Column",
                "width": "stretch",
                "items": [
                    {
                        "type": "TextBlock",
                        "text": "FPW",
                        "weight": "Bolder",
                        "id": "FPWtxt",
                        "horizontalAlignment": "Center"
                    }
                ]
            },
            {
                "type": "Column",
                "width": "stretch",
                "items": [
                    {
                        "type": "TextBlock",
                        "text": "Serving Size",
                        "id": "ServingSizetxt",
                        "horizontalAlignment": "Center",
                        "weight": "Bolder"
                    }
                ]
            }
        ]
    },
    {
        "type": "ColumnSet",
        "columns": [
            {
                "type": "Column",
                "width": "stretch",
                "items": [
                    {
                        "type": "FactSet",
                        "facts": [
                            {
                                "$data": "{propertiesNutritional}",
                                "title": "{key}",
                                "value": "{value}"
                            }
                        ],
                        "id": "NutritionalFact",
                        "separator": true,
                        "spacing": "None"
                    }
                ]
            },
            {
                "type": "Column",
                "width": "stretch",
                "items": [
                    {
                        "type": "FactSet",
                        "facts": [
                            {
                                "$data": "{propertiesUom}",
                                "title": "{key}",
                                "value": "{value}"
                            }
                        ],
                        "id": "UomFact",
                        "separator": true,
                        "spacing": "None"
                    }
                ]
            },
            {
                "type": "Column",
                "width": "stretch",
                "items": [
                    {
                        "type": "FactSet",
                        "facts": [
                            {
                                "$data": "{propertiesCurrentA}",
                                "title": "{key}",
                                "value": "{value}"
                            }
                        ],
                        "id": "CurrentFact1",
                        "separator": true,
                        "spacing": "None"
                    }
                ]
            },
            {
                "type": "Column",
                "width": "stretch",
                "items": [
                    {
                        "type": "FactSet",
                        "facts": [
                            {
                                "$data": "{propertiesNewA}",
                                "title": "{key}",
                                "value": "{value}"
                            }
                        ],
                        "id": "NewFact1",
                        "spacing": "None",
                        "separator": true
                    }
                ]
            },
            {
                "type": "Column",
                "width": "stretch",
                "items": [
                    {
                        "type": "FactSet",
                        "facts": [
                            {
                                "$data": "{propertiesCurrentB}",
                                "title": "{key}",
                                "value": "{value}"
                            }
                        ],
                        "id": "CurrentFact2",
                        "separator": true,
                        "spacing": "None"
                    }
                ]
            },
            {
                "type": "Column",
                "width": "stretch",
                "items": [
                    {
                        "type": "FactSet",
                        "facts": [
                            {
                                "$data": "{propertiesNewB}",
                                "title": "{key}",
                                "value": "{value}"
                            }
                        ],
                        "id": "NewFact2",
                        "separator": true,
                        "spacing": "None"
                    }
                ]
            },
            {
                "type": "Column",
                "width": "stretch",
                "items": [
                    {
                        "type": "FactSet",
                        "facts": [
                            {
                                "$data": "{propertiesCurrentC}",
                                "title": "{key}",
                                "value": "{value}"
                            }
                        ],
                        "id": "CurrentFact3",
                        "separator": true,
                        "spacing": "None"
                    }
                ]
            },
            {
                "type": "Column",
                "width": "stretch",
                "items": [
                    {
                        "type": "FactSet",
                        "facts": [
                            {
                                "$data": "{propertiesNewC}",
                                "title": "{key}",
                                "value": "{value}"
                            }
                        ],
                        "id": "NewFact3",
                        "spacing": "None",
                        "separator": true
                    }
                ]
            }
        ]
    }
],
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json"

}

这是您的数据:

    {
    "propertiesNutritional": [{
        "key": "Nutritional",
        "value": "Calories"
    }],
    "propertiesUom": [{
        "key": "UOM",
        "value": "Calories"
    }],
    "propertiesCurrentA": [{
        "key": "Current",
        "value": "Number"

    }],
    "propertiesNewA": [{
        "key": "New",
        "value": "Number"
    }],
    "propertiesCurrentB": [{
        "key": "Current",
        "value": "Number"

    }],
    "propertiesNewB": [{
        "key": "New",
        "value": "Number"
    }],
    "propertiesCurrentC": [{
        "key": "Current",
        "value": "Number"

    }],
    "propertiesNewC": [{
        "key": "New",
        "value": "Number"
    }]
}