Pre-Flatten Nested JSON Strings So Set Works With Simple Mappings Only
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.Run Manual Trigger; Sample Records emits fictional items with nested JSON strings
- 2.Parse And Flatten parses any string starting with { or [ into dot-path typed fields
- 3.Broken JSON is tagged failed with reason invalid_json_text and kept in field__unresolved
- 4.Map Flat Fields assigns record_id, status and counters using simple assignments plus includeOtherFields
- 5.If compares unresolved_json_marker to empty and sends leftovers to Review Queue
- 6.Review and clean NoOp nodes feed two separate Merge inputs in append mode
- 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
- Import the JSON and click Execute Workflow
- Confirm REC-1001 and REC-1003 are resolved with flattened dot-path keys
- Confirm REC-1002 is failed with invalid_json_text and route review
- Add a record without record_id and verify NO_ID-n generation
- 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
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 (9)
Manual Trigger
Manual Trigger
Sample Records
Code
Parse And Flatten
Code
Map Flat Fields
Set
Has Unresolved JSON Text?
If
Review Queue
No Op
Mapped Clean
No Op
Merge Branches
Merge
Build Report
Code
Note Parsing Stage
Sticky Note
Note Mapping Stage
Sticky Note
Note Routing And Report
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