Schema Inferrer icon

Schema Inferrer

Infer JSON schema from one or multiple input JSON data items

Prepare for Database

AI-generated

Overview

This node operation prepares data for insertion into PostgreSQL JSONB/JSON columns by serializing nested objects or arrays according to a provided JSON schema. It is useful before performing PostgreSQL Insert or Upsert operations when the data contains complex nested structures that need to be stored as JSON strings in the database.

Use Case Examples

  1. Use this node to convert nested JSON objects in your data into JSON strings based on a schema before inserting into a PostgreSQL JSONB column.
  2. Prepare data with nested arrays for database insertion by serializing those arrays as JSON strings using the schema provided.

Properties

Name Meaning
Schema A JSON schema used to identify which fields in the data need to be serialized as JSON strings for PostgreSQL JSONB/JSON columns.
Skip Already Stringified Option to skip fields that are already valid JSON strings to avoid double-stringification.
Pretty Print Option to format JSON strings with indentation (2 spaces) for readability.
Strict Mode Option to throw an error if the schema is missing or invalid; otherwise, log a warning and skip transformation.

Output

JSON

  • preparedData - The data after being processed and prepared for insertion into PostgreSQL JSONB/JSON columns, with nested objects/arrays serialized as JSON strings according to the schema.

Dependencies

  • Requires a JSON schema input, typically generated from the 'Create Schema' operation, to identify JSON fields.

Troubleshooting

  • If the schema is missing or invalid and strict mode is enabled, the node will throw an error. Ensure the schema is correctly provided.
  • If data fields are already stringified JSON and 'Skip Already Stringified' is false, double stringification may occur, causing errors in the database. Enable skipping to avoid this.
  • Pretty print option may increase data size; disable it if compact storage is preferred.

Discussion