Skip to content
Data & Databases

Pre-Flatten Nested JSON Strings So Set Works With Simple Mappings Only

9 nodes 41 3 Manual trigger
Download

Loading workflow…

Workflow Description

A manual, self-contained workflow that separates parsing from mapping. One Code node performs every JSON.parse: it detects string fields starting with a JSON bracket, parses and flattens them into dot-path keys with explicit string/number/boolean types, and tags each field as resolved or failed with reason invalid_json_text without aborting the run. A Set node then applies only direct typed assignments with includeOtherFields enabled. An If node checks the unresolved marker and routes leftover raw JSON text to a NoOp review path; both branches append into Merge, and a final Code node emits one aggregated report matching the input record count.

How it works

  1. 1.Run Manual Trigger; Sample Records emits fictional items with nested JSON strings
  2. 2.Parse And Flatten parses any string starting with { or [ into dot-path typed fields
  3. 3.Broken JSON is tagged failed with reason invalid_json_text and kept in field__unresolved
  4. 4.Map Flat Fields assigns record_id, status and counters using simple assignments plus includeOtherFields
  5. 5.If compares unresolved_json_marker to empty and sends leftovers to Review Queue
  6. 6.Review and clean NoOp nodes feed two separate Merge inputs in append mode
  7. 7.Build Report (runOnceForAllItems) returns exactly one report sorted by record_id

Use cases

  • Avoid failing JSON.parse expressions inside Set nodes on n8n Cloud
  • Flatten webhook payloads delivered as a JSON string in one field
  • Detect fields that remain unresolved JSON text before downstream stages
  • Produce a parsing-quality report for a batch of records

Requirements

  • n8n 2.46.4 or newer
  • No credentials needed for the manual demo
  • For real data replace Sample Records with Webhook, HTTP Request or a DB node using the same schema
  • Fields intended for parsing must start with { or [

Setup and testing in n8n

  1. Import the JSON and click Execute Workflow
  2. Confirm REC-1001 and REC-1003 are resolved with flattened dot-path keys
  3. Confirm REC-1002 is failed with invalid_json_text and route review
  4. Add a record without record_id and verify NO_ID-n generation
  5. Empty the records array and verify a zeroed report with an empty records list

Service Value

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

Apps Used

Manual Trigger Code Set If No Op Merge

Details

Trigger Manual trigger
Nodes 9
Apps 6
Views 41
Downloads 3

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

/

Manual Trigger

Manual Trigger

#1

Sample Records

Code

#2

Parse And Flatten

Code

#3

Map Flat Fields

Set

#4

Has Unresolved JSON Text?

If

#5

Review Queue

No Op

#6

Mapped Clean

No Op

#7

Merge Branches

Merge

#8

Build Report

Code

#9

Note Parsing Stage

Sticky Note

#10

Note Mapping Stage

Sticky Note

#11

Note Routing And Report

Sticky Note

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