【问题标题】:Liquid template transformation is not working in Azure Logic app液体模板转换在 Azure 逻辑应用中不起作用
【发布时间】:2019-10-15 09:52:21
【问题描述】:

我正在尝试使用逻辑应用程序执行 json -> json 转换。下面是逻辑应用代码。转换没有按预期工作。不知道是什么问题。我已经在在线液体沙箱中测试了模板,我没有发现任何问题。

 {
    "definition": {
        "$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
        "actions": {
            "Response": {
                "inputs": {
                    "body": "@body('Transform_JSON_to_JSON')",
                    "statusCode": 200
                },
                "kind": "Http",
                "runAfter": {
                    "Transform_JSON_to_JSON": [
                        "Succeeded"
                    ]
                },
                "type": "Response"
            },
            "Transform_JSON_to_JSON": {
                "inputs": {
                    "content": "@triggerBody()",
                    "integrationAccount": {
                        "map": {
                            "name": "lqd"
                        }
                    }
                },
                "kind": "JsonToJson",
                "runAfter": {},
                "type": "Liquid"
            }
        },
        "contentVersion": "1.0.0.0",
        "outputs": {},
        "parameters": {},
        "triggers": {
            "manual": {
                "inputs": {
                    "schema": {}
                },
                "kind": "Http",
                "type": "Request"
            }
        }
    }
}

模板:

{
"name" : "{{firstName}} {{lastName}}"
}

输入:

{
 "firstName": "Jack",
 "LastName": "Jill" 
}

预期输出:

{
"name" : "Jack Jill"
}

逻辑应用的实际输出:

{
  "name": " "
}

【问题讨论】:

    标签: azure azure-logic-apps dotliquid liquid-template


    【解决方案1】:

    这适用于以下模板

    {
    "name" : "{{content.firstName}} {{content.lastName}}"
    }
    

    【讨论】:

      【解决方案2】:

      液体转换是 JSON 转换的高级版本。它应该用于复杂的 JSON 场景。如果您有简单的 JSON,则应使用 Compose 或 Parse JSON。

      原因:当数据字符串有特殊字符双引号时,液体转换失败。因此,为避免动作转换失败,请使用 Compose 或 Parse JSON。

      【讨论】:

        【解决方案3】:

        只是添加安居的回复:

        Azure Logic App - Issue with double quotes in Liquid Map 有一种非常简单的方法可以解决双引号问题:

        "quotedText":'{{ fieldThatContainsDoubleQuotes }}'
        

        【讨论】:

          猜你喜欢
          • 1970-01-01
          • 2020-02-01
          • 1970-01-01
          • 2021-05-13
          • 1970-01-01
          • 1970-01-01
          • 1970-01-01
          • 2018-10-04
          • 1970-01-01
          相关资源
          最近更新 更多