YAML icon

YAML

Convert data to YAML or from YAML

Overview

This node provides various operations to work with YAML data, including extracting data from YAML, converting JSON to YAML and vice versa, and specifically for the "Set value in YAML" operation, it allows modifying YAML content by setting or updating specific fields within the YAML structure.

The "Set value in YAML" operation is useful when you have YAML data and want to programmatically update or add values at specified paths inside that YAML. This can be beneficial in automation workflows where configuration files or structured data in YAML format need to be dynamically adjusted based on other workflow inputs or conditions.

Practical examples:

  • Updating a Kubernetes deployment YAML file with new image tags or replica counts.
  • Modifying a YAML-based configuration file for an application before deployment.
  • Adding or changing nested properties in a YAML document used for infrastructure as code.

Properties

Name Meaning
Input Yaml Field The name of the property in the input item that contains the YAML data to modify. For example, if your YAML is stored under data, set this to "data".
Fields to Set A collection of fields specifying which YAML paths to set or update. Each field includes:
- Name: The path to the field in dot notation (supports arrays, e.g., person[0].name).
- Type: The type of the value to set.
- Value: The actual value to assign, supporting types String, Number, Boolean, Array, or Object.
Input Type Specifies the format of the input data containing the YAML:
- Binary: Input is binary data.
- String: Input is a string.
- Auto detecting: Automatically detect input type.
Binary Options Options relevant if input type is binary:
- File Encoding: Encoding of the binary file (default UTF-8).
- Strip BOM: Whether to remove Byte Order Mark for certain encodings.
- Keep Source: Whether to keep JSON, binary, or both data from the input item.
Set Options Additional options for setting values:
- Ignore Type Conversion Errors: If enabled, the node will apply less strict type conversion and ignore errors related to type mismatches when setting values.

Output

The output contains the modified items with the updated YAML data reflected in the specified property (the same property as the input YAML field). The structure of the json output field mirrors the input but with the specified fields updated according to the user's configuration.

If the input was binary, the output may also include binary data depending on the "Keep Source" option.

No explicit binary output is generated by this operation itself; it primarily modifies YAML content within JSON or string fields.

Dependencies

  • No external services or API keys are required.
  • The node depends on internal YAML parsing and serialization libraries bundled within the node's implementation.
  • Proper encoding settings must be configured if working with binary input to correctly interpret the YAML content.

Troubleshooting

  • Incorrect field paths: Using invalid or incorrectly formatted dot-notation paths in "Fields to Set" may cause the node to fail to update the intended YAML fields. Verify paths carefully.
  • Type conversion errors: If the value type does not match the expected type in YAML, the node might throw errors unless "Ignore Type Conversion Errors" is enabled.
  • Encoding issues: When using binary input, incorrect file encoding settings can lead to parsing failures or corrupted output. Ensure the correct encoding is selected.
  • Empty or malformed YAML input: If the input YAML is empty or invalid, the node will fail to parse and update it. Validate YAML input beforehand.

Links and References

Discussion