Select Fields Node Settings
This is useful for removing unnecessary data, renaming fields, or preparing data for subsequent nodes that expect a particular structure.
Configuration Options
The settings panel for the Select Fields Node provides the following options:
Property | Description | Controls |
---|---|---|
Label | A custom name for this node in the graph. Helps in identifying the node's purpose. | Text input field. |
Fields to Select | Define the fields to be selected from the input data. Each entry specifies the path to the input field and the desired name for the output field.
| A list of input pairs. Each pair has:
|
Input Data Structure
The Select Fields node can process either a single JSON object or an array of JSON objects.
- If the input is a single object, the output will be a single object containing only the selected fields.
- If the input is an array of objects, the output will be an array of objects, where each object has been transformed according to the field selections.
How it Works
- The node receives an input JSON object or an array of JSON objects.
- For each object (or the single input object): a. It iterates through the "Fields to Select" list. b. For each entry, it uses the "Input Path" to extract the value from the current object. c. The extracted value is assigned to a new field in an output object. The name of this new field is determined by "Output Name", or the original field name if "Output Name" is empty.
- The resulting object (or array of objects) is passed to the node's output.
Important Considerations
- JSONPath Syntax: Ensure your "Input Path" expressions correctly follow JSONPath syntax. Incorrect paths may result in
null
values or errors. For example, to select thename
property from an object like{"user": {"name": "John"}}
, the path would beuser.name
. For an array of items like[{"id": 1}, {"id": 2}]
where you want all IDs, you might use[*].id
. - Field Naming: "Output Name" allows you to rename fields. If an "Output Name" is not provided, the last segment of the "Input Path" is used as the field name. For example, if "Input Path" is
customer.address.street
and "Output Name" is empty, the output field will be namedstreet
. - Non-existent Paths: If an "Input Path" does not exist in the input object, the corresponding field will typically be omitted from the output or assigned a
null
value, depending on the specific implementation details. - Data Transformation: This node is primarily for selection and renaming. For more complex data transformations (e.g., calculations, conditional logic on values), consider using a "Code Node" or "Transform Node".
Example Scenario
Imagine your input data is:
{
"orderId": "123",
"customerDetails": {
"firstName": "John",
"lastName": "Doe",
"email": "john.doe@example.com"
},
"items": [
{ "productId": "A1", "quantity": 2 },
{ "productId": "B2", "quantity": 1 }
],
"totalAmount": 150.00
}
You configure the "Fields to Select" as follows:
- Input Path:
orderId
, Output Name:OrderNumber
- Input Path:
customerDetails.email
, Output Name:CustomerEmail
- Input Path:
items
, Output Name:Products
The output will be:
{
"OrderNumber": "123",
"CustomerEmail": "john.doe@example.com",
"Products": [
{ "productId": "A1", "quantity": 2 },
{ "productId": "B2", "quantity": 1 }
]
}
This panel allows for precise control over the data structure passed through your workflow, ensuring that subsequent nodes receive only the information they need in the format they expect.