Skip to content
Data & Databases

Nested Array Inventory: Path, Count and Depth Stats Before Splitting

8 nodes 60 5 Manual trigger
Download

Loading workflow…

Workflow Description

A fully local workflow that turns any nested JSON payload into a precise inventory of every array it contains. A Code node walks the structure recursively and records, for each array, its full dot/bracket path, element count, path depth, array nesting depth and element kind. An IF node separates non-empty paths from empty and invalid ones, a Set node creates an array-typed field ready for splitting only for non-empty paths, a Merge node in append mode joins both branches, and a final Code node emits one sorted report item with no network calls.

How it works

  1. 1.Manual Trigger starts the run with an empty item
  2. 2.A Code node emits two demo payloads: a valid nested order and an invalid null payload
  3. 3.A Code node walks the structure recursively and emits one item per array path with stats
  4. 4.An IF node checks itemCount > 0 and routes the paths
  5. 5.A Set node adds array-typed splitField plus splitFieldName while keeping other fields
  6. 6.A NoOp node collects empty and invalid paths
  7. 7.Merge (append, 2 inputs) joins both branches in one execution
  8. 8.A final Code node (runOnceForAllItems) returns a single alphabetically sorted inventory report

Use cases

  • Inspect a nested API payload before building Split Out nodes
  • Detect empty arrays that break splitting
  • Measure array nesting depth to plan how many unwrap stages are needed
  • Document a response structure for a development team

Requirements

  • n8n 2.47.7 or compatible
  • No credentials and no network access needed
  • For real data: replace the sample Code node with a Webhook or HTTP Request node exposing a payload field

Setup and testing in n8n

  1. Import the JSON into n8n
  2. Run Execute Workflow and open the Build Inventory Report output
  3. Confirm seven array paths plus one invalid-payload row appear
  4. Add another empty array to the sample payload and verify it appears only in emptyArrayPaths
  5. Pass payload: null or a string to verify invalidPayloads increases

Service Value

Ready-made workflow template for automation delivery and service execution.

Apps Used

Manual Trigger Code If Set No Op Merge

Details

Trigger Manual trigger
Nodes 8
Apps 6
Views 60
Downloads 5

How to Use

  1. 1.Click "Download Template"
  2. 2.Open your n8n dashboard
  3. 3.Go to Workflows > Import from File
  4. 4.Select downloaded file and configure credentials

Nodes Used (8)

/

Manual Trigger

Manual Trigger

#1

Load Sample Payloads

Code

#2

Inventory Array Paths

Code

#3

Has Elements?

If

#4

Prepare Split Field

Set

#5

Empty Or Invalid Paths

No Op

#6

Merge Both Branches

Merge

#7

Build Inventory Report

Code

#8

Note Input Stage

Sticky Note

#9

Note Inventory Stage

Sticky Note

#10

Note Routing And Report

Sticky Note

#11
Stay in the loop

Fresh workflows, straight to your inbox

Get newly published DROPIDEA workflows, a clear overview of what they do, and a link to explore them.

  • New workflows
  • Clear overviews
  • Setup guides

Be first to discover what is new

Your name, your email, and one confirmation.

Email confirmation · Unsubscribe anytime