json - Azure 逻辑应用程序返回难以使用的 json 字符串

标签 json azure azure-functions azure-logic-apps

我目前正试图将 JSON 字符串转换为可用的格式。

数据最初位于 pandas 数据框中,我将其以 JSON 格式存储在 azure blob 存储容器中。然后我使用了这个 Compose base64(outputs('Get_blob_content_(V2)')?['body']) ,然后使用 base64ToString(outputs('Compose')) 将 JSON 文件推送为字符串数据类型。

之后我使用 Parse JSON 函数解析了它。

My current Attempt

目前,当我通过电子邮件发送时,我收到了各种 JSON 条目的列表。我想把它变成表格格式或表格格式。我已经尝试了 CSV 和 HTML 函数选项,但都没有执行任何操作。

enter image description here

最佳答案

从我们端复制后,我们可以使用以下流程来实现您的要求。

enter image description here

下面是我正在处理的 json

{
  "0": "2022-08-12 16:00:00",
  "1": "2022-09-05 16:00:00",
  "2": "2022-09-05 16:00:00",
  "3": "2022-09-01 16:00:00",
  "4": "2022-09-03 16:00:00",
  "5": "2022-09-21 16:00:00",
  "6": "2022-09-23 16:00:00",
  "7": "2022-09-29 10:00:00",
  "8": "2022-10-07 16:00:00",
  "9": "2022-09-30 16:00:00",
  "10": "2022-10-07 17:00:00",
  "11": "2022-10-21 16:00:00"
}

enter image description here

创建 HTML 表中,我实际上使用了解析 JSON 的结果。

enter image description here

结果:

下面是我的逻辑应用中的成功运行

enter image description here

在我的邮件中

enter image description here

这是我的逻辑应用的代码 View

{
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Compose": {
                "inputs": {
                    "0": "2022-08-12 16:00:00",
                    "1": "2022-09-05 16:00:00",
                    "2": "2022-09-05 16:00:00",
                    "3": "2022-09-01 16:00:00",
                    "4": "2022-09-03 16:00:00",
                    "5": "2022-09-21 16:00:00",
                    "6": "2022-09-23 16:00:00",
                    "7": "2022-09-29 10:00:00",
                    "8": "2022-10-07 16:00:00",
                    "9": "2022-09-30 16:00:00",
                    "10": "2022-10-07 17:00:00",
                    "11": "2022-10-21 16:00:00"
                },
                "runAfter": {},
                "type": "Compose"
            },
            "Create_HTML_table": {
                "inputs": {
                    "columns": [
                        {
                            "header": "0",
                            "value": "@body('Parse_JSON')?['0']"
                        },
                        {
                            "header": "1",
                            "value": "@body('Parse_JSON')?['1']"
                        },
                        {
                            "header": "2",
                            "value": "@body('Parse_JSON')?['2']"
                        },
                        {
                            "header": "3",
                            "value": "@body('Parse_JSON')?['3']"
                        },
                        {
                            "header": "4",
                            "value": "@body('Parse_JSON')?['4']"
                        },
                        {
                            "header": "5",
                            "value": "@body('Parse_JSON')?['5']"
                        },
                        {
                            "header": "6",
                            "value": "@body('Parse_JSON')?['6']"
                        },
                        {
                            "header": "7",
                            "value": "@body('Parse_JSON')?['7']"
                        },
                        {
                            "header": "8",
                            "value": "@body('Parse_JSON')?['8']"
                        },
                        {
                            "header": "9",
                            "value": "@body('Parse_JSON')?['9']"
                        },
                        {
                            "header": "10",
                            "value": "@body('Parse_JSON')?['10']"
                        },
                        {
                            "header": "11",
                            "value": "@body('Parse_JSON')?['11']"
                        }
                    ],
                    "format": "HTML",
                    "from": "@array(outputs('Compose'))"
                },
                "runAfter": {
                    "Parse_JSON": [
                        "Succeeded"
                    ]
                },
                "type": "Table"
            },
            "Parse_JSON": {
                "inputs": {
                    "content": "@outputs('Compose')",
                    "schema": {
                        "properties": {
                            "0": {
                                "type": "string"
                            },
                            "1": {
                                "type": "string"
                            },
                            "2": {
                                "type": "string"
                            },
                            "3": {
                                "type": "string"
                            },
                            "4": {
                                "type": "string"
                            },
                            "5": {
                                "type": "string"
                            },
                            "6": {
                                "type": "string"
                            },
                            "7": {
                                "type": "string"
                            },
                            "8": {
                                "type": "string"
                            },
                            "9": {
                                "type": "string"
                            },
                            "10": {
                                "type": "string"
                            },
                            "11": {
                                "type": "string"
                            }
                        },
                        "type": "object"
                    }
                },
                "runAfter": {
                    "Compose": [
                        "Succeeded"
                    ]
                },
                "type": "ParseJson"
            },
            "Send_an_email_(V2)": {
                "inputs": {
                    "body": {
                        "Body": "<p>@{body('Create_HTML_table')}</p>",
                        "Importance": "Normal",
                        "Subject": "HTML Table",
                        "To": "<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="11673c6266746579707a70517c7872637e627e77653f727e7c" rel="noreferrer noopener nofollow">[email protected]</a>"
                    },
                    "host": {
                        "connection": {
                            "name": "@parameters('$connections')['office365']['connectionId']"
                        }
                    },
                    "method": "post",
                    "path": "/v2/Mail"
                },
                "runAfter": {
                    "Create_HTML_table": [
                        "Succeeded"
                    ]
                },
                "type": "ApiConnection"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {
            "$connections": {
                "defaultValue": {},
                "type": "Object"
            }
        },
        "triggers": {
            "manual": {
                "inputs": {
                    "schema": {}
                },
                "kind": "Http",
                "type": "Request"
            }
        }
    },
    "parameters": {
        "$connections": {
            "value": {
                "office365": {
                    "connectionId": "/subscriptions/<SubId>/resourceGroups/<RG>/providers/Microsoft.Web/connections/office365",
                    "connectionName": "office365",
                    "id": "/subscriptions/<SubId>/providers/Microsoft.Web/locations/centralus/managedApis/office365"
                }
            }
        }
    }
}

关于json - Azure 逻辑应用程序返回难以使用的 json 字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/73322594/

相关文章:

azure - 在 Azure Function 中访问 Azure Key Vault secret

在混合插槽中调用 Azure Durable Functions

本地 Azure 函数 - 为什么使用 Docker 容器?

javascript - 为什么我无法通过ajax将数据发送到.json格式文件

javascript - 尝试将对象添加到 Javascript 对象数组时出现“意外标记 d”

json - SwiftyJSON - 无法解析 Json

node.js - 我应该在 NPM package.json 中将 "start"脚本设置为什么?

azure - 如何让 Microsoft Storage Explorer 计算 ContentMD5

azure - 我的 Azure Web 应用程序无法从正确的 appsetting.{env}.json 文件中读取参数

sql-server - 停止/启动 Azure SQL Server 托管实例