簡體   English   中英

液體模板 - 物品 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"
        }
      ]
    }
  ]
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM