🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

n8n-nodes-json-storage

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

n8n-nodes-json-storage

n8n node for storing and retrieving key-value pairs in a JSON file

latest
npmnpm
Version
0.1.6
Version published
Weekly downloads
2
Maintainers
1
Weekly downloads
 
Created
Source

n8n-nodes-json-storage

This is an n8n community node for storing and retrieving key-value pairs in a JSON file.

Features

  • Save key-value pairs in a JSON file
  • Read values by key from the JSON file
  • Values are stored in base64 format for security
  • Simple and easy to use
  • Custom file path support
  • Consistent JSON output format

Operations

Save

Saves a key-value pair to the JSON file. If the key already exists, its value will be updated.

Parameters:

  • Key: The key to save
  • Value: The value to save
  • File Path: Full path to the JSON file where data will be stored

Output format:

{
  "success": true,
  "key": "your-key",
  "value": "your-value"
}

Read

Reads a value by key from the JSON file.

Parameters:

  • Key: The key to retrieve
  • File Path: Full path to the JSON file where data is stored

Output format (key found):

{
  "success": true,
  "key": "your-key",
  "value": "stored-value"
}

Output format (key not found):

{
  "success": false,
  "key": "your-key",
  "value": ""
}

Installation

Follow these steps to install this node in your n8n instance:

  • git clone ...
  • npm pack
  • upload or copy in your n8n installation user ".n8n/custom" directory For example if your user is www-data this directory will be: ~www-data/.n8n/custom
  • Run the following command:
    npm install n8n-nodes-json-storage
    
  • Restart n8n

Usage Examples

Save a value

  • Create a new workflow
  • Add a "JSON Storage" node
  • Select the "Save" operation
  • Enter a key and a value
  • Configure the file path (default is [working-directory]/data/custom_json.json)
  • Execute the node

Read a value

  • Create a new workflow
  • Add a "JSON Storage" node
  • Select the "Read" operation
  • Enter the key to retrieve
  • Ensure the file path matches the one used for saving
  • Execute the node

Notes

  • By default, data is stored in a "data" directory in your specified path
  • Directories will be created automatically if they don't exist
  • Values are encoded in base64 before saving to the file
  • The operation will fail if the JSON file exists but has invalid format

Developer Notes

Managing the "this" context in JavaScript

When developing n8n nodes, it's important to understand how the this context works in JavaScript.

Problem

The error this.someMethod is not a function typically occurs when a method loses its binding to the class instance. This happens in the following scenarios:

  • When methods are passed as callbacks
  • When methods are called from a different context
  • When using separated method implementations that rely on the class context

Solutions

There are several ways to solve this issue:

  • Inline implementation: Define the logic directly in the main method (like we did in v0.1.4)

    async execute() {
      // Implement logic directly here instead of in separate methods
    }
    
  • Bind methods in constructor:

    constructor() {
      this.saveOperation = this.saveOperation.bind(this);
      this.readOperation = this.readOperation.bind(this);
    }
    
  • Use arrow functions (which preserve the lexical this):

    saveOperation = async (items, returnData, storage, filePath) => {
      // Method implementation
    }
    
  • Pass this explicitly:

    await this.saveOperation.call(this, items, returnData, storage, filePath);
    

For n8n nodes, the safest approach is either using inline implementations or explicitly binding methods in the constructor.

Version History

  • 0.1.6 - Standardized JSON output format for both save and read operations
  • 0.1.5 - Simplified read output when key is not found
  • 0.1.4 - Fixed "this.readOperation is not a function" error by implementing functions inline
  • 0.1.3 - Added custom file path support, automatic directory creation
  • 0.1.2 - Added working directory and home directory information
  • 0.1.1 - Fixed compatibility issues
  • 0.1.0 - Initial release

Keywords

n8n-community-node-package

FAQs

Package last updated on 06 Mar 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts