Azure Bot -将数据从json payload格式化为自适应卡时存在问题

hjzp0vay  于 2023-04-07  发布在  其他
关注(0)|答案(1)|浏览(147)

我目前正在开发一个机器人,它会触发一个HTTP请求到远程端点。该端点处理通用请求。有效负载是动态的,具体取决于请求类型。这些请求的示例包括:

  • 获取用户的AD信息vs设置AD或AzureAD组信息vs联系其他API

输出示例如下。此外,一旦(那些)特殊字符被删除,我需要迭代通过每个填充的项目只和渲染他们在一个自适应卡

{
  "lgType": "Activity",
  "text": [
    {
      "GivenName": "john",
      "Surname": "doe",
      "UserPrincipalName": "jdoe@domain.com",
      "Enabled": true,
      "SamAccountName": "jdoe",
      "SID": {
        "BinaryLength": 28,
        "AccountDomainSid": {
          "BinaryLength": 24,
          "AccountDomainSid": {
            "BinaryLength": 24,
            "AccountDomainSid": {
              "BinaryLength": 24,
              "AccountDomainSid": "S-2-2-17-438902509-970237201-892232075",
              "Value": "S-2-2-17-438902509-970237201-892232075"
            },
            "Value": "S-2-2-17-438902509-970237201-892232075"
          },
          "Value": "S-2-2-17-438902509-970237201-892232075"
        },
        "Value": "S-2-2-17-438902509-970237201-892232075"
      },
      "DistinguishedName": "CN=Doe\, John,OU=HQ,DC=domain,DC=com",
      "Name": "Doe, John",
      "ObjectClass": "user",
      "ObjectGuid": "39e4466a-3644-40ce-2317-c0d3a6c45f4mc0",
      "PropertyNames": [
        "DistinguishedName",
        "Enabled",
        "GivenName",
        "Name",
        "ObjectClass",
        "ObjectGUID",
        "SamAccountName",
        "SID",
        "Surname",
        "UserPrincipalName"
      ],
      "AddedProperties": [],
      "RemovedProperties": [],
      "ModifiedProperties": [],
      "PropertyCount": 10,
      "ObjectGUID": "39e4466a-3644-40ce-2317-c0d3a6c45f4mc0"
    }
  ]
}

删除字符:

我试过很多不同的方法

  • @“replace('${dialog.API_response}','','')”
  • @“replace('${dialog.API_response.text}','','')”

迭代json payload:

{
      ${generateList()}
      "type": "TextBlock",
      "text": foreach(json("${dialog.api_response.text}"), x, concat(x.key, ':', x.value))
      "isSubtle": false
    }

任何帮助,协助和指导将不胜感激

vfwfrxfs

vfwfrxfs1#

下面是一个如何从字符串中删除反斜杠字符的示例:

const stringWithBackslash = "CN=Doe\\, John,OU=HQ,DC=domain,DC=com";
const stringWithoutBackslash = stringWithBackslash.replace(/\\/g, "");
console.log(stringWithoutBackslash); // Output: "CN=Doe, John,OU=HQ,DC=domain,DC=com"

相关问题