Serializes a CFML value (struct, array, or scalar) to a YAML string and returns it. When a file path is supplied, the YAML is also written to that file. Struct keys beginning with two underscores are skipped, mirroring serializeJSON. The charset argument is accepted but ignored (output is UTF-8).
yamlSerialize(data [, filePath, charset])
→ returns string
utf8Returns the YAML string.
data = { name = "Alex", age = 30 };
yaml = yamlSerialize(data);
Expected Result: name: Alex age: 30
The YAML string is returned and also written to the file.
yaml = yamlSerialize(data, expandPath("./config.yaml"));
Signup for cfbreak to stay updated on the latest news from the ColdFusion / CFML community. One email, every friday.