Skip to content
AI Agents

Subarray Key Promotion to Category Column with Sorted Reverse Index

11 nodes 91 6 Manual trigger
Download

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. 1.Run Manual Trigger; a Code node emits a fictional payload with two subarrays and one single object
  2. 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. 3.A Set node locks the row structure while keeping all original fields
  4. 4.A Code node builds and descending-sorts the reverse index
  5. 5.An IF node checks totals and emits success or failure reports
  6. 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

  1. Import the JSON, run Manual Trigger, expect one report: 3 categories, 6 rows, matchPassed=true
  2. Edit the sample: remove an array or add another single object and rerun to confirm normalization
  3. 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

Manual Trigger Code Set If Merge No Op

Details

Trigger Manual trigger
Nodes 11
Apps 6
Views 91
Downloads 6

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 (11)

/

Manual Trigger

Manual Trigger

#1

Emit Fictional CRM Payload

Code

#2

Normalize and Promote Subarray Keys

Code

#3

Standardize Flattened Row

Set

#4

Build Sorted Reverse Index

Code

#5

Verify Totals Match

If

#6

Match Success Report

Code

#7

Match Failure Report

Code

#8

Merge Report Branches

Merge

#9

Assemble Final Report

Code

#10

Delivery Terminal

No Op

#11

Docs: Input Schema

Sticky Note

#12

Docs: Flatten and Index

Sticky Note

#13
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