JSON Database icon

JSON Database

Reads/writes data from/to a JSON file acting as an hierarchical key-value database

Overview

The Read From Database operation of the "JSON Database" node reads data from a JSON file, treating it as a hierarchical key-value database. This allows users to extract specific values or objects from a structured JSON file using a path expression. Common scenarios include:

  • Retrieving configuration or reference data stored in a JSON file.
  • Accessing nested data structures for further processing in an n8n workflow.
  • Querying custom databases or logs maintained in JSON format.

Practical Example:
Suppose you have a JSON file storing user profiles and want to retrieve the email address of a specific user. You can specify the query path to extract just that value.

Properties

Name Meaning
Query Path Path on which to act on in the JSON tree (leave empty to select root). Example: users["john"].email
File Path Path to the JSON file in which to read/write the data (leave empty to use the default global database)

Output

The output is a JSON object with the following structure:

{
  "data": <value at the specified query path>
}
  • If Query Path is empty, the entire JSON file content is returned under data.
  • If Query Path points to a specific property, only that property's value is returned under data.

Dependencies

  • File System Access: The node requires access to the file system where the JSON file is located.
  • Default Global Database: If no file path is provided, a default global JSON file is used (JsonDatabase.Global.json).
  • No external API keys or services are required.

Troubleshooting

Common Issues:

  • File Not Found: If the specified file does not exist, the node will return an error.
  • Invalid Query Path: If the query path does not match any property in the JSON, data will be undefined.
  • File Permissions: Lack of read permissions on the target file will cause errors.
  • Locked Database: If the database is locked by another process for too long, you may see:
    • "The database is being kept locked for too much time. Try again later."
      • Resolution: Wait and retry, or check if another process is holding the lock.

Error Handling:

  • If "Continue On Fail" is enabled, errors are reported in the output as { "error": "<message>" } per item.

Links and References

Discussion