液体模板 - 项目 ID

Liquid Template - Item ID

有人可以帮助我如何使用液体模板从下面拉出 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,我们将不胜感激。

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

{     
    "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"
        }
      ]
    }
  ]
}