CAPI Utils icon

CAPI Utils

Funções utilitárias de JavaScript para manipulação de JSON, arrays, strings e expressões regulares dentro do n8n.

Dados (JSON, arrays ou objetos)

AI-generated

Overview

This node, named 'CAPI Utils', provides utility functions for manipulating JSON data structures, arrays, and objects within n8n workflows. It supports various guided operations such as filtering items by a field, removing fields, picking specific fields, removing duplicates, sorting, extracting values, counting items, and selecting the first or last item. This node is useful for data transformation tasks where users need to process and reshape JSON data dynamically based on specific criteria. For example, it can filter a list of user records by email, remove unwanted fields from each record, or sort items by a date field.

Use Case Examples

  1. Filtering a list of JSON objects to keep only those where the 'status' field equals 'active'.
  2. Removing the 'password' field from each user object in an array for security reasons.
  3. Extracting a list of email addresses from a collection of user objects.
  4. Sorting an array of orders by the 'orderDate' field in descending order.

Properties

Name Meaning
Guia rápido Provides a quick guide on how to use the node for JSON data operations.
Passo 2 • O que você quer fazer? Selects the JSON operation to perform, such as filtering, removing fields, sorting, etc.
Passo 3 • Onde estão os dados de entrada? JSON path indicating where the input data is located within the incoming JSON object.
Onde salvar o resultado? JSON path where the result of the operation will be saved. Can overwrite the input data or use a new path.
Qual campo devemos analisar? The name of the field inside each item to analyze or operate on, used in applicable operations.
Qual valor você quer comparar? The exact value to compare against when filtering items by field.
Quais campos devem permanecer? Comma-separated list of fields to keep when picking specific fields from items.
Qual ordem aplicar? Sort order to apply when sorting items by a field, ascending or descending.

Output

JSON

  • outputPropertyName - The JSON path where the transformed data is saved, containing the result of the selected JSON operation.

Troubleshooting

  • Ensure the input JSON path specified in 'dataPropertyName' exists and contains data; otherwise, the node throws an error indicating no data found at the path.
  • When using operations that require a field name (e.g., filterByField, removeField), ensure the 'fieldName' parameter is correctly set to a valid field inside each item.
  • For the 'pickFields' operation, at least one field must be specified in the 'fields' parameter; otherwise, an error is thrown.
  • If the output property path is the same as the input, the original data will be overwritten; use a different path to preserve original data.

Links

Discussion