Filter out items in array

Hi there,
I have this json:

[
  {
    "order_id": 3483,
    "shop": "de",
    "email": "c70f1444c4d13c512a556dfaaf2770c9b67f8b6f10f85fc7cc957984a6800dc1",
    "line_items": [
      {
        "id": 3551,
        "name": "Bezug für Sessel Muren altes Modell - Blue A13",
        "product_id": 1128,
        "variation_id": 1137,
        "quantity": 1,
        "tax_class": "",
        "subtotal": "149.00",
        "subtotal_tax": "0.00",
        "total": "149.00",
        "total_tax": "0.00",
        "taxes": [],
        "meta_data": [
          {
            "id": 29116,
            "key": "pa_natural-color",
            "value": "a13",
            "display_key": "Farbe",
            "display_value": "Blue A13"
          },
          {
            "id": 29127,
            "key": "_reduced_stock",
            "value": "1",
            "display_key": "_reduced_stock",
            "display_value": "1"
          }
        ],
        "sku": "E12",
        "price": 149,
        "image": {
          "id": 674,
          "src": "https://dagra.eu/de/wp-content/uploads/sites/3/E12_A13-2.jpg"
        },
        "parent_name": "Bezug für Sessel Muren altes Modell"
      }
    ]
  },
  {
    "order_id": 3482,
    "shop": "de",
    "email": "11528819a3cbf9ace9fea3d1c433aa6dd3c4c0f2ffa0679559feb0481c0dc7a2",
    "line_items": [
      {
        "id": 3549,
        "name": "Gesteppter Bezug für 3er-Bettsofa Beddinge Streifen - Beige L25",
        "product_id": 26,
        "variation_id": 1985,
        "quantity": 1,
        "tax_class": "",
        "subtotal": "119.00",
        "subtotal_tax": "0.00",
        "total": "119.00",
        "total_tax": "0.00",
        "taxes": [],
        "meta_data": [
          {
            "id": 29095,
            "key": "pa_lux-color",
            "value": "l25",
            "display_key": "Farbe",
            "display_value": "Beige L25"
          },
          {
            "id": 29106,
            "key": "_reduced_stock",
            "value": "1",
            "display_key": "_reduced_stock",
            "display_value": "1"
          }
        ],
        "sku": "B01",
        "price": 119,
        "image": {
          "id": 1981,
          "src": "https://dagra.eu/de/wp-content/uploads/sites/3/B01_L25-6.jpg"
        },
        "parent_name": "Gesteppter Bezug für 3er-Bettsofa Beddinge Streifen"
      }
    ]
  },
  {
    "order_id": 3480,
    "shop": "de",
    "email": "97fa871a9b99e3c894bedfe990aaac079fad5a2593cf2bfb4439e8620cf0ae79",
    "line_items": [
      {
        "id": 3546,
        "name": "Gesteppter Bezug für 3er-Bettsofa Beddinge Streifen - Pastel Mint L29",
        "product_id": 26,
        "variation_id": 37,
        "quantity": 1,
        "tax_class": "",
        "subtotal": "119.00",
        "subtotal_tax": "0.00",
        "total": "119.00",
        "total_tax": "0.00",
        "taxes": [],
        "meta_data": [
          {
            "id": 29063,
            "key": "pa_lux-color",
            "value": "l29",
            "display_key": "Farbe",
            "display_value": "Pastel Mint L29"
          },
          {
            "id": 29084,
            "key": "_reduced_stock",
            "value": "1",
            "display_key": "_reduced_stock",
            "display_value": "1"
          }
        ],
        "sku": "B01",
        "price": 119,
        "image": {
          "id": 162,
          "src": "https://dagra.eu/de/wp-content/uploads/sites/3/B01_L29-6.jpg"
        },
        "parent_name": "Gesteppter Bezug für 3er-Bettsofa Beddinge Streifen"
      },
      {
        "id": 3547,
        "name": "Kissenbezug für das Modell Beddinge - Pastel Mint L29",
        "product_id": 329,
        "variation_id": 330,
        "quantity": 2,
        "tax_class": "",
        "subtotal": "18.00",
        "subtotal_tax": "0.00",
        "total": "18.00",
        "total_tax": "0.00",
        "taxes": [],
        "meta_data": [
          {
            "id": 29073,
            "key": "pa_lux-color",
            "value": "l29",
            "display_key": "Farbe",
            "display_value": "Pastel Mint L29"
          },
          {
            "id": 29085,
            "key": "_reduced_stock",
            "value": "2",
            "display_key": "_reduced_stock",
            "display_value": "2"
          }
        ],
        "sku": "B03",
        "price": 9,
        "image": {
          "id": 311,
          "src": "https://dagra.eu/de/wp-content/uploads/sites/3/B03_L29.jpg"
        },
        "parent_name": "Kissenbezug für das Modell Beddinge"
      }
    ]
  },
  {
    "order_id": 3479,
    "shop": "de",
    "email": "b58beafd77d56ca2911f326b53c7d459835d43cea3b1ffdba4c53a52a2857721",
    "line_items": [
      {
        "id": 3544,
        "name": "Gesteppter Bezug für 3er-Bettsofa Beddinge Streifen - Dark gray L06",
        "product_id": 26,
        "variation_id": 45,
        "quantity": 1,
        "tax_class": "",
        "subtotal": "119.00",
        "subtotal_tax": "0.00",
        "total": "119.00",
        "total_tax": "0.00",
        "taxes": [],
        "meta_data": [
          {
            "id": 29042,
            "key": "pa_lux-color",
            "value": "l06",
            "display_key": "Farbe",
            "display_value": "Dark gray L06"
          },
          {
            "id": 29053,
            "key": "_reduced_stock",
            "value": "1",
            "display_key": "_reduced_stock",
            "display_value": "1"
          }
        ],
        "sku": "B01",
        "price": 119,
        "image": {
          "id": 200,
          "src": "https://dagra.eu/de/wp-content/uploads/sites/3/B01_L06-2.jpg"
        },
        "parent_name": "Gesteppter Bezug für 3er-Bettsofa Beddinge Streifen"
      }
    ]
  },
  {
    "order_id": 3478,
    "shop": "de",
    "email": "1f6efab31bdb145edd16a5ce064367495e127f20f7c5535f44c4c8daede8e6cd",
    "line_items": [
      {
        "id": 3541,
        "name": "Gesteppter Bezug für 3er-Bettsofa Beddinge Streifen - Dark gray L06",
        "product_id": 26,
        "variation_id": 45,
        "quantity": 1,
        "tax_class": "",
        "subtotal": "119.00",
        "subtotal_tax": "0.00",
        "total": "119.00",
        "total_tax": "0.00",
        "taxes": [],
        "meta_data": [
          {
            "id": 29010,
            "key": "pa_lux-color",
            "value": "l06",
            "display_key": "Farbe",
            "display_value": "Dark gray L06"
          },
          {
            "id": 29031,
            "key": "_reduced_stock",
            "value": "1",
            "display_key": "_reduced_stock",
            "display_value": "1"
          }
        ],
        "sku": "B01",
        "price": 119,
        "image": {
          "id": 200,
          "src": "https://dagra.eu/de/wp-content/uploads/sites/3/B01_L06-2.jpg"
        },
        "parent_name": "Gesteppter Bezug für 3er-Bettsofa Beddinge Streifen"
      },
      {
        "id": 3542,
        "name": "Bezug für Armlehne-Kissen Beddinge - Dark gray L06",
        "product_id": 318,
        "variation_id": 327,
        "quantity": 2,
        "tax_class": "",
        "subtotal": "28.00",
        "subtotal_tax": "0.00",
        "total": "28.00",
        "total_tax": "0.00",
        "taxes": [],
        "meta_data": [
          {
            "id": 29020,
            "key": "pa_lux-color",
            "value": "l06",
            "display_key": "Farbe",
            "display_value": "Dark gray L06"
          },
          {
            "id": 29032,
            "key": "_reduced_stock",
            "value": "2",
            "display_key": "_reduced_stock",
            "display_value": "2"
          }
        ],
        "sku": "B05",
        "price": 14,
        "image": {
          "id": 287,
          "src": "https://dagra.eu/de/wp-content/uploads/sites/3/B05_L06.jpg"
        },
        "parent_name": "Bezug für Armlehne-Kissen Beddinge"
      }
    ]
  }
]

And from “line_items” I want to left only id, name and quantity

Definitely a task for JMESPath. You can overwrite your line_items array with the return value using a Set node.

Here’s an example workflow. I don’t know if it’s the most optimal JMESPath expression but it works:

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.