Overview
The yaml-parser node converts between YAML strings and
JavaScript objects. Parse YAML configuration files, Kubernetes manifests, Docker Compose files,
and other YAML-based data into usable objects, or stringify objects back to YAML format.
Properties
| Property | Type | Default | Description |
|---|---|---|---|
| action | string | "parse" | "parse" (YAML string → object) or "stringify" (object → YAML string) |
Example: Parse Configuration File
Parse a YAML configuration file into a structured object.
// yaml-parser node configuration
{
"action": "parse"
}
// Input YAML string in msg.payload.data:
// "device:
// name: sensor-01
// type: temperature
// interval: 5000
// thresholds:
// warning: 30
// critical: 45
// notifications:
// - email
// - slack"
// Output after parsing:
{
"payload": {
"data": {
"device": {
"name": "sensor-01",
"type": "temperature",
"interval": 5000
},
"thresholds": {
"warning": 30,
"critical": 45
},
"notifications": ["email", "slack"]
}
}
}
// Flow: [file-read config.yaml] → [yaml-parser] → [set node] Example: Parse Docker Compose
Read and parse a Docker Compose file to extract service information.
// yaml-parser node configuration
{
"action": "parse"
}
// Input from file-read docker-compose.yml:
// "version: '3.8'
// services:
// edgeflow:
// image: edgeflow:latest
// ports:
// - '8080:8080'
// environment:
// - NODE_ENV=production"
// Output:
{
"payload": {
"data": {
"version": "3.8",
"services": {
"edgeflow": {
"image": "edgeflow:latest",
"ports": ["8080:8080"],
"environment": ["NODE_ENV=production"]
}
}
}
}
}
// Access: msg.payload.data.services.edgeflow.image Example: Generate YAML Output
Convert a configuration object into YAML format for saving to a file.
// yaml-parser node configuration
{
"action": "stringify"
}
// Input object in msg.payload.data:
{
"payload": {
"data": {
"sensors": [
{ "id": "temp-01", "type": "DHT22", "pin": 4 },
{ "id": "light-01", "type": "BH1750", "bus": 1 }
],
"interval": 5000,
"logging": true
}
}
}
// Output YAML string in msg.payload.data:
// "sensors:
// - id: temp-01
// type: DHT22
// pin: 4
// - id: light-01
// type: BH1750
// bus: 1
// interval: 5000
// logging: true"
// Flow: [function build config] → [yaml-parser stringify] → [file-write] Common Use Cases
Configuration Management
Read and write YAML config files for applications and services
Kubernetes / Docker
Parse and generate K8s manifests and Docker Compose files
CI/CD Pipelines
Read GitHub Actions, GitLab CI, and other pipeline configs
Data Interchange
Convert between YAML, JSON, and other structured formats