Subarray Key Promotion to Category Column with Sorted Reverse Index
Loading workflow…
Workflow Description
A manual-trigger workflow that flattens a payload containing subarrays and a single object normalized to an array, promotes each subarray key to a category column with a _parent_ref to the parent array, builds an aggregated reverse index (category → row id list and count) sorted descending by count, verifies via IF that the index total equals the flattened row count, and uses Merge plus a final Code node to assemble one report with category count, row count and the match result.
How it works
- 1.Run Manual Trigger; a Code node emits a fictional payload with two subarrays and one single object
- 2.A Code node normalizes the single object to an array, then flattens every subarray promoting its key to category, _parent_ref and row_id
- 3.A Set node locks the row structure while keeping all original fields
- 4.A Code node builds and descending-sorts the reverse index
- 5.An IF node checks totals and emits success or failure reports
- 6.Merge collects branches and a final Code node returns one combined report
Use cases
- Locally flattening nested CRM/API payloads without credentials
- Aggregated reports sorted by category size
- Auditing that no rows are lost during JSON flattening
Requirements
- No credentials needed; fully local with supported nodes
- To use real data: wire a Webhook or HTTP Request node with the same schema in place of the sample node
Setup and testing in n8n
- Import the JSON, run Manual Trigger, expect one report: 3 categories, 6 rows, matchPassed=true
- Edit the sample: remove an array or add another single object and rerun to confirm normalization
- Test edge cases: empty values or non-object rows get wrapped as value without loss
Service Value
Ready-made workflow template for automation delivery and service execution.
Apps Used
Details
How to Use
- 1.Click "Download Template"
- 2.Open your n8n dashboard
- 3.Go to Workflows > Import from File
- 4.Select downloaded file and configure credentials
Nodes Used (11)
Manual Trigger
Manual Trigger
Emit Fictional CRM Payload
Code
Normalize and Promote Subarray Keys
Code
Standardize Flattened Row
Set
Build Sorted Reverse Index
Code
Verify Totals Match
If
Match Success Report
Code
Match Failure Report
Code
Merge Report Branches
Merge
Assemble Final Report
Code
Delivery Terminal
No Op
Docs: Input Schema
Sticky Note
Docs: Flatten and Index
Sticky Note
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