Export to JSON file
This node saves data to a JSON file.
The Export to JSON file (Write To Json) node allows you to download an array or object as a file.
The Export to JSON file node takes an array (or object) and triggers a browser download of that data formatted as a JSON file. This is useful for backing up data, exporting reports, or saving user configurations.
Data
| Data | Description |
|---|
| Array | The data to export. Can be an array or an object. |
Control
| Signal | Description |
|---|
| Do | Triggers the export process. |
Outputs
Control
| Signal | Description |
|---|
| Done | Triggered when the download starts. |
Status
| Data | Description |
|---|
| File Path | The name of the downloaded file (e.g., ). |
| Error | Error message if the export fails. |
Usage
Backup Data
- Fetch all records from a database using Filter Records.
- Connect the Items array to the Array input of this node.
- Add a "Export" button.
- Connect Button Click to Do.
- The user will be prompted to save the file.
Detailed Behavior
- Environment:
- Browser: Creates a Blob and triggers a programmatic click on a hidden link to start the download.
- Node.js: Writes the file to the local filesystem.
- Formatting: The JSON is pretty-printed with 2-space indentation for readability.
Troubleshooting
- Popup Blocked: Some browsers might block the download if it's not triggered directly by a user action. Ensure the Do signal comes from a click event.