我目前正试图将 JSON 字符串转换为可用的格式。
数据最初位于 pandas 数据框中,我将其以 JSON 格式存储在 azure blob 存储容器中。然后我使用了这个 Compose base64(outputs('Get_blob_content_(V2)')?['body']) ,然后使用 base64ToString(outputs('Compose')) 将 JSON 文件推送为字符串数据类型。
之后我使用 Parse JSON 函数解析了它。
目前,当我通过电子邮件发送时,我收到了各种 JSON 条目的列表。我想把它变成表格格式或表格格式。我已经尝试了 CSV 和 HTML 函数选项,但都没有执行任何操作。
最佳答案
从我们端复制后,我们可以使用以下流程来实现您的要求。
下面是我正在处理的 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"
}
在创建 HTML 表
中,我实际上使用了解析 JSON 的结果。
结果:
下面是我的逻辑应用中的成功运行
在我的邮件中
这是我的逻辑应用的代码 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/