【问题标题】:Liquid Template - Item ID液体模板 - 物品 ID
【发布时间】:2021-03-19 16:31:52
【问题描述】:

有人可以帮助我如何使用液体模板从下面提取 itemid 吗?:

{
  "orders": [
    {
      "id": 3688882438313,
      "line_items": [
        {
          "id": 9698678243497
        },
        {
          "id": 9698678276265
            }
          ]
        }
      ]
    }

I can get the order id from the following template:

{     
   "Order" : [   
      {% for order in content.orders%}      
      {          
         "ID" : "{{ order.id }}",
      },  
      {% endfor %}   
   ]
}

但无论我如何尝试,似乎都无法提取项目 ID,我们将不胜感激。

【问题讨论】:

  • 我提供了一个液体样本来获取 itemId 供您参考,如果您想要其他 json 格式的 itemId 作为结果,请告诉我并提供您想要的格式的样本。
  • 嗨,这篇文章有什么更新吗?
  • 谢谢,非常感谢。工作一种享受。我现在遇到的问题是尝试包含 if 或过滤器。
  • 如果您原来的问题已经解决,能否请您将我的回答标记为“已接受”,谢谢。对于您的新问题,请提供更多详细信息,说明您希望如何包含“if”或“filter”?您想通过包含“if”或“filter”来实现什么?那我会继续帮你解决的。
  • 非常感谢。

标签: azure liquid azure-logic-apps dotliquid


【解决方案1】:

根据您的要求,这里提供一个液体样品供您参考:

{     
    "Order" : [   
        {% for order in content.orders%}      
            {          
                "ID" : "{{ order.id }}",
                "ItemIds": [
                    {% for item in order.line_items%}
                        {
                            "itemId": "{{item.id}}"
                        },
                    {% endfor %}
                ]
            },  
        {% endfor %}   
    ]
}

运行上面的液体,我们可以得到结果:

{
  "Order": [
    {
      "ID": "3688882438313",
      "ItemIds": [
        {
          "itemId": "9698678243497"
        },
        {
          "itemId": "9698678276265"
        }
      ]
    }
  ]
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2011-08-22
    • 2014-11-29
    • 1970-01-01
    • 1970-01-01
    • 2022-11-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多