AutomationFlowsGeneral › Process JSON Arrays into Product Reports

Process JSON Arrays into Product Reports

Original n8n title: Array Operations

Array Operations. Uses start, json. Manual trigger; 5 nodes.

Manual trigger★★★★☆ complexity5 nodesStartJSON
General Trigger: Manual Nodes: 5 Complexity: ★★★★☆ Added:

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "name": "Array Operations",
  "description": "Advanced array manipulation including filtering, mapping, sorting, and aggregation",
  "category": "data-transformation",
  "difficulty": "intermediate",
  "estimatedTime": "15 minutes",
  "prerequisites": [
    "Understanding of arrays",
    "Basic expression knowledge"
  ],
  "learningObjectives": [
    "Master array manipulation functions",
    "Learn filtering and mapping techniques",
    "Practice aggregation operations"
  ],
  "nodes": [
    {
      "parameters": {},
      "id": "start",
      "name": "Start",
      "type": "n8n-nodes-base.start",
      "typeVersion": 1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "assignments": [
          {
            "name": "products",
            "value": "[{\"id\": 1, \"name\": \"Laptop\", \"category\": \"Electronics\", \"price\": 999.99, \"stock\": 15, \"rating\": 4.5, \"tags\": [\"computer\", \"portable\", \"business\"]}, {\"id\": 2, \"name\": \"Smartphone\", \"category\": \"Electronics\", \"price\": 699.99, \"stock\": 25, \"rating\": 4.2, \"tags\": [\"mobile\", \"communication\", \"portable\"]}, {\"id\": 3, \"name\": \"Coffee Maker\", \"category\": \"Appliances\", \"price\": 89.99, \"stock\": 8, \"rating\": 4.0, \"tags\": [\"kitchen\", \"coffee\", \"appliance\"]}, {\"id\": 4, \"name\": \"Desk Chair\", \"category\": \"Furniture\", \"price\": 199.99, \"stock\": 12, \"rating\": 4.3, \"tags\": [\"office\", \"seating\", \"ergonomic\"]}, {\"id\": 5, \"name\": \"Tablet\", \"category\": \"Electronics\", \"price\": 329.99, \"stock\": 20, \"rating\": 4.1, \"tags\": [\"portable\", \"touchscreen\", \"entertainment\"]}]"
          }
        ]
      },
      "id": "set-product-data",
      "name": "Set Product Data",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "operation": "parse",
        "jsonPath": "$json.products"
      },
      "id": "parse-products",
      "name": "Parse Products",
      "type": "n8n-nodes-base.json",
      "typeVersion": 1,
      "position": [
        680,
        300
      ]
    },
    {
      "parameters": {
        "assignments": [
          {
            "name": "highValueProducts",
            "value": "{{ $json.data.filter(product => product.price > 300) }}"
          },
          {
            "name": "electronicsCount",
            "value": "{{ length($json.data.filter(product => product.category === 'Electronics')) }}"
          },
          {
            "name": "averagePrice",
            "value": "{{ round(sum($json.data.map(product => product.price)) / length($json.data), 2) }}"
          },
          {
            "name": "averageRating",
            "value": "{{ round(sum($json.data.map(product => product.rating)) / length($json.data), 2) }}"
          },
          {
            "name": "totalStock",
            "value": "{{ sum($json.data.map(product => product.stock)) }}"
          },
          {
            "name": "maxPrice",
            "value": "{{ max($json.data.map(product => product.price)) }}"
          },
          {
            "name": "minPrice",
            "value": "{{ min($json.data.map(product => product.price)) }}"
          },
          {
            "name": "productsByPrice",
            "value": "{{ $json.data.sort((a, b) => b.price - a.price) }}"
          },
          {
            "name": "productsByRating",
            "value": "{{ $json.data.sort((a, b) => b.rating - a.rating) }}"
          },
          {
            "name": "lowStockProducts",
            "value": "{{ $json.data.filter(product => product.stock < 10) }}"
          },
          {
            "name": "categories",
            "value": "{{ unique($json.data.map(product => product.category)) }}"
          },
          {
            "name": "allTags",
            "value": "{{ unique($json.data.flatMap(product => product.tags)) }}"
          },
          {
            "name": "productCount",
            "value": "{{ length($json.data) }}"
          }
        ]
      },
      "id": "analyze-products",
      "name": "Analyze Products",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        900,
        300
      ]
    },
    {
      "parameters": {
        "assignments": [
          {
            "name": "summary",
            "value": "{{ 'Analyzed ' + $json.productCount + ' products across ' + length($json.categories) + ' categories with average price $' + $json.averagePrice }}"
          },
          {
            "name": "insights",
            "value": "{{ {highValueCount: length($json.highValueProducts), lowStockCount: length($json.lowStockProducts), priceRange: {min: $json.minPrice, max: $json.maxPrice}, stockStatus: $json.totalStock > 50 ? 'Good' : 'Low'} }}"
          },
          {
            "name": "reportGenerated",
            "value": "{{ formatDate(now(), 'yyyy-MM-dd HH:mm:ss') }}"
          }
        ]
      },
      "id": "generate-report",
      "name": "Generate Report",
      "type": "n8n-nodes-base.set",
      "typeVersion": 1,
      "position": [
        1120,
        300
      ]
    }
  ],
  "connections": {
    "Start": {
      "main": [
        [
          {
            "node": "Set Product Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set Product Data": {
      "main": [
        [
          {
            "node": "Parse Products",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Products": {
      "main": [
        [
          {
            "node": "Analyze Products",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze Products": {
      "main": [
        [
          {
            "node": "Generate Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {},
  "versionId": "1"
}
Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Array Operations. Uses start, json. Manual trigger; 5 nodes.

Source: https://github.com/neul-labs/m9m/blob/main/examples/data-transformation/array-operations.json — original creator credit. Request a take-down →

More General workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

General

Conditional Routing. Uses start, json. Manual trigger; 10 nodes.

Start, JSON
General

JSON Processing. Uses start, json. Manual trigger; 6 nodes.

Start, JSON
General

Smoke Test - Multi-Step Pipeline. Uses start, json. Manual trigger; 5 nodes.

Start, JSON
General

Data Processing. Uses start, json. Manual trigger; 4 nodes.

Start, JSON
General

Smoke Test - JSON Node. Uses start, json. Manual trigger; 3 nodes.

Start, JSON