Supplier catalogs

How to choose the leaf category from a JSON categories array

2026-06-29
Task

Each product has a JSON categories array with levels 1, 2, and 3. The import needs the third-level leaf category.

Short answer

Open name inside categories and add a condition on neighboring level: regular expression ^3$ (matches a value that is exactly 3).

How to do it in Eofferix

  1. In the JSON snapshot, select name inside the categories array.

    JSON field name
    The selected field belongs to one category object.
  2. Open the value settings.

    Opening name settings
    The animation shows opening the field settings.
  3. Add an export condition: level ^3$.

    JSON condition
    The condition selects only the needed array item before export.

Before / after

Before

source data
{
    "products": [
        {
            "sku": "SKU-20001",
            "name": "Hudson lamp",
            "categories": [
                {
                    "level": 1,
                    "name": "Lighting"
                },
                {
                    "level": 2,
                    "name": "Table lamps"
                },
                {
                    "level": 3,
                    "name": "LED lamps"
                }
            ]
        },
        {
            "sku": "SKU-20002",
            "name": "Parker chair",
            "categories": [
                {
                    "level": 1,
                    "name": "Lighting"
                },
                {
                    "level": 2,
                    "name": "Table lamps"
                }
            ]
        }
    ]
}

After

result
{
    "products": [
        {
            "sku": "SKU-20001",
            "name": "Hudson lamp",
            "category": "LED lamps"
        },
        {
            "sku": "SKU-20002",
            "name": "Parker chair",
            "category": null
        }
    ]
}

What to keep in mind

  • If the needed level is always one fixed value, use equals 3 without a regular expression.
  • If some products do not have level 3, they will have no leaf category value.

Process data faster with Eofferix

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

Sign up