Supplier catalogs

How to take stock from a JSON warehouses array by warehouse_id

2026-06-29
Task

Each JSON product has a warehouses array. The import needs stock only from warehouse ny-main, while reserve warehouses must not fill this field.

Short answer

Open qty inside warehouses and add a condition on neighboring warehouse_id: regular expression ^ny-main$ (matches a value that is exactly ny-main).

How to do it in Eofferix

  1. In the JSON snapshot, select qty inside the warehouses array.

    JSON field qty
    The selected field belongs to one warehouse object.
  2. Open the value settings.

    Opening qty settings
    The animation shows opening the field settings.
  3. Method 1: on neighboring warehouse_id, set Equals ny-main.

    JSON condition
    This is one condition variant; the other variants do not need to be added.
  4. Method 2: keep regular expression ^ny-main$ (matches a value that is exactly ny-main) as the strict option.

    JSON condition
    This is one condition variant; the other variants do not need to be added.

Before / after

Before

source data
{
    "products": [
        {
            "sku": "SKU-25001",
            "name": "Hudson lamp",
            "warehouses": [
                {
                    "warehouse_id": "ny-main",
                    "qty": 14
                },
                {
                    "warehouse_id": "la-reserve",
                    "qty": 6
                }
            ]
        },
        {
            "sku": "SKU-25002",
            "name": "Parker chair",
            "warehouses": [
                {
                    "warehouse_id": "ny-main",
                    "qty": 0
                },
                {
                    "warehouse_id": "la-reserve",
                    "qty": 5
                }
            ]
        }
    ]
}

After

result
{
    "products": [
        {
            "sku": "SKU-25001",
            "name": "Hudson lamp",
            "stock": 14
        },
        {
            "sku": "SKU-25002",
            "name": "Parker chair",
            "stock": 0
        }
    ]
}

Process data faster with Eofferix

Create a free account to automate catalogs and price lists around your own rules.

Sign up