Recovery vs Corruption Classifier for Double-Serialized Fields and [object Object]
Loading workflow…
Workflow Description
A fully local workflow: a Manual Trigger feeds a Code node that emits fictional records containing a once-serialized JSON string, a double-serialized JSON string, a field literally holding [object Object], and an empty string. The classifier Code node scans every string field: the literal marker means unrecoverable corruption; otherwise repeated JSON.parse runs until the value stabilises, recording serialization depth and the parsed value; everything else stays plain text. An IF node splits corrupted from recoverable records, a Merge node appends both routes, and a final Code node returns exactly one sorted report item shown by a NoOp node.
How it works
- 1.Manual Trigger sends one empty item to the sample generator.
- 2.Load Sample Records emits 4 records: once-serialized, double-serialized, containing [object Object], and an empty string field.
- 3.Classify Serialization Depth inspects each string field and labels it corrupted, recovered with depth, or plain text.
- 4.IF evaluates has_corrupted: output 0 corrupted, output 1 recovered/clean.
- 5.Two Set nodes add a route field with includeOtherFields:true so classification data is preserved.
- 6.Merge in append mode joins both routes through separate inputs.
- 7.Build Single Report (runOnceForAllItems) returns one report item sorted by record_id, displayed by the NoOp node.
Use cases
- Audit webhook payloads whose nested objects were implicitly stringified.
- Decide which fields can be salvaged with JSON.parse and which are permanently lost.
- Measure double-serialization depth in data arriving from middleware.
- Produce a data-quality report before database insertion.
Requirements
- n8n 2.46.4 or newer; no credentials needed since the workflow is self-contained.
- For real data, replace Load Sample Records with a Webhook or HTTP Request node returning flat objects with string fields.
- Keep both Code nodes in runOnceForAllItems mode.
Setup and testing in n8n
- Import the JSON into n8n and click Execute Workflow.
- Check REC-001 has depth 1 and REC-002 depth 2 with the correct parsed object.
- Check REC-003 status is corrupted and body appears in corrupted_fields.
- Check REC-004 status is clean and the empty string field is in plain_text_fields.
- Edge case: make the sample node return an empty array and confirm the report yields total_records = 0 without errors.
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
Load Sample Records
Code
Classify Serialization Depth
Code
Has Corrupted Field?
If
Tag Corrupted Route
Set
Tag Recoverable Route
Set
Merge Branches
Merge
Build Single Report
Code
Final Report Output
No Op
Note Stages
Sticky Note
Note Classifier
Sticky Note
Note Routing
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