Dump one or more YAML _documents to the file/stream.
Set indentation width. 2 by default. Must not be zero.
Specify tag directives.
Write to a file
auto node = Node([1, 2, 3, 4, 5]); dumper().dump(new Appender!string(), node);
Write multiple YAML documents to a file
auto node1 = Node([1, 2, 3, 4, 5]); auto node2 = Node("This document contains only one string"); dumper().dump(new Appender!string(), node1, node2); //Or with an array: dumper().dump(new Appender!string(), [node1, node2]);
Write to memory
auto stream = new Appender!string(); auto node = Node([1, 2, 3, 4, 5]); dumper().dump(stream, node);
Use a custom resolver to support custom data types and/or implicit tags
import std.regex : regex; auto node = Node([1, 2, 3, 4, 5]); auto dumper = dumper(); dumper.resolver.addImplicitResolver("!tag", regex("A.*"), "A"); dumper.dump(new Appender!string(), node);
Set default scalar style
auto stream = new Appender!string(); auto node = Node("Hello world!"); auto dumper = dumper(); dumper.defaultScalarStyle = ScalarStyle.singleQuoted; dumper.dump(stream, node);
Set default collection style
auto stream = new Appender!string(); auto node = Node(["Hello", "world!"]); auto dumper = dumper(); dumper.defaultCollectionStyle = CollectionStyle.flow; dumper.dump(stream, node);