【问题标题】:How to use substring operation in liquid json to json transformation?如何在液体 json 到 json 转换中使用子字符串操作?
【发布时间】:2020-03-04 10:05:19
【问题描述】:

我正在使用逻辑应用程序中的集成帐户使用 Json 到 Json 转换。

我的输入是 -

{"MyText" : "S-12-678"}

预期输出 -

{
"First-Data":"678",
"Second-Data":"S-12"
}

对于高于预期的输出,我创建了mydemo.liquid 文件,如下所示,适用于First-Data 字段但无法获得"Second-Data":"S-12" 如何实现?

{
   "First-Data": "{{content.MyText | Split: '-' | Last }}",
   "Second-Data": "{{content.MyText | Split: '-' | First}}"
}

【问题讨论】:

    标签: json azure azure-logic-apps dotliquid


    【解决方案1】:

    您可以使用下面的液体模板:

    {% assign arr = content.MyText | Split: "-" %}
    {
        "First-Data": "{{arr[2]}}",
        "Second-Data": "{{arr[0]}}-{{arr[1]}}"
    }
    

    那么结果就是你所期望的:

    【讨论】:

    • 哦,是的,我在寻找子字符串表达式谢谢:)
    猜你喜欢
    • 1970-01-01
    • 2021-07-21
    • 1970-01-01
    • 1970-01-01
    • 2014-05-28
    • 2017-01-02
    • 2011-03-08
    相关资源
    最近更新 更多