Streamline Your Data Transformation with Mock Data and Array Creation
detail.loadingPreview
Effortlessly generate and transform mock data with n8n. This workflow demonstrates how to create a structured array of custom objects from initial mock data, perfect for testing and development.
About This Workflow
This n8n workflow snippet showcases a powerful yet simple approach to data manipulation. The 'Mock Data' node generates a predefined set of user objects, each with a unique ID and name. The subsequent 'Create an array of objects' node takes this initial data and elegantly consolidates it into a single JSON object, where the 'data_object' key holds an array of all the generated user data. This is invaluable for developers needing to quickly spin up test data, simulate API responses, or prepare data for further processing within complex automation pipelines. Its simplicity belies its utility in accelerating development cycles and ensuring robust testing environments.
Key Features
- Dynamic Mock Data Generation: Easily create and customize initial data sets.
- Array Consolidation: Efficiently group multiple data items into a single structured array.
- Code-Based Flexibility: Leverage JavaScript for precise control over data transformations.
- Simplified Testing & Development: Accelerate your development workflow with ready-to-use test data.
How To Use
- Add the 'Mock Data' Node: Search for and add the 'Function' node to your n8n canvas.
- Configure 'Mock Data' Node: In the node's settings, replace the default code with the provided JavaScript function to define your mock data objects (e.g.,
return [{ json: { id: 1, name: "Jim" } }, ...]). - Add the 'Create an array of objects' Node: Add another 'Function' node to your canvas.
- Configure 'Create an array of objects' Node: In this node's settings, use the provided JavaScript function:
return [{ json: { data_object: items.map(item => item.json) } }]. This maps the incoming data (items) into a new object under thedata_objectkey. - Connect the Nodes: Draw an arrow from the 'Mock Data' node's output to the 'Create an array of objects' node's input.
Apps Used
Workflow JSON
{
"id": "bcaf7184-ebb7-492e-9f46-fe7452feea24",
"name": "Streamline Your Data Transformation with Mock Data and Array Creation",
"nodes": 11,
"category": "DevOps",
"status": "active",
"version": "1.0.0"
}Note: This is a sample preview. The full workflow JSON contains node configurations, credentials placeholders, and execution logic.
Get This Workflow
ID: bcaf7184-ebb7...
About the Author
SaaS_Connector
Integration Guru
Connecting CRM, Notion, and Slack to automate your life.
Statistics
Related Workflows
Discover more workflows you might like
Automate Qualys Report Generation and Retrieval
Streamline your Qualys security reporting by automating the generation and retrieval of reports. This workflow ensures timely access to crucial security data without manual intervention.
Automated PR Merged QA Notifications
Streamline your QA process with this automated workflow that notifies your team upon successful Pull Request merges. Leverage AI and vector stores to enrich notifications and ensure seamless integration into your development pipeline.
Visualize Your n8n Workflows: Interactive Dashboard with Mermaid.js
Gain unparalleled visibility into your n8n automation landscape. This workflow transforms your n8n instance into a dynamic, interactive dashboard, leveraging Mermaid.js to visualize all your workflows in one accessible place.