Insert JSON icon

Insert JSON

Insert or replace JSON data in the JSON Vault

Insert JSON

AI-generated

Overview

This node inserts or replaces JSON data in a global JSON Vault within an n8n workflow. It allows users to store JSON data at a specified key, supporting nested paths using dot notation. The node can either replace existing data at the key or merge new data with existing objects. It is useful for workflows that require centralized JSON data storage and manipulation, such as aggregating user data, configuration settings, or intermediate results across multiple workflow executions.

Use Case Examples

  1. Storing user profile data under the key 'users.profile' for later retrieval.
  2. Merging new configuration settings into an existing JSON object stored at 'config.settings'.
  3. Replacing an entire JSON object at a key like 'session.data' with fresh data from a previous node.

Properties

Name Meaning
Key The key to store the JSON data. Supports nested paths with dots (e.g., 'users.admin'). This determines where in the JSON Vault the data will be inserted or updated.
JSON Data The JSON object or value to insert. Can be provided manually as a JSON string/object or taken from the previous node's output.
Merge Mode Determines how to handle existing values at the key. 'Replace' overwrites the entire value, while 'Deep Merge' merges the new data with the existing object (only applicable for objects).
Data Source Specifies where to get the JSON data from. 'Manual Entry' allows entering JSON data manually, while 'From Input' uses data from the previous node.

Output

JSON

  • json
    • success - Indicates if the operation was successful (true or false).
    • key - The key where the JSON data was inserted or updated.
    • action - The action performed, e.g., 'inserted'.
    • vaultSize - The number of keys currently stored in the JSON Vault.
    • vault - The entire JSON Vault object after the operation.
    • keys - An array of all keys currently stored in the JSON Vault.
    • count - The count of keys in the JSON Vault, same as vaultSize.

Dependencies

  • Requires access to a global static data storage within the workflow to maintain the JSON Vault state.

Troubleshooting

  • Error if the 'Key' parameter is empty or invalid format; ensure the key contains only letters, numbers, dots, hyphens, and underscores.
  • Error if trying to insert data at a key that already exists when using 'Replace' mode; use 'Deep Merge' mode to update existing keys or use a different node for updates.
  • Errors related to JSON parsing if the manual JSON data input is malformed; ensure valid JSON format.
  • Vault size validation errors if the JSON Vault grows too large; monitor and manage the size of stored data.

Discussion