Dumping YAML Documents topic

You can dump documents by calling dumpYamlDocuments. This package exposes YamlDocument which can only be constructed when an object is parsed. This is intentional. The root node of the YamlDocument will be dumped as a CompactYamlNode.

const source = '''
%TAG !reproducible! !reproducible
---
!reproducible!sequence [
  !!str &anchor value,
  *anchor ,
  !tag [ *anchor , 24 ],
]
''';

print(
  dumpYamlDocuments(YamlParser(source).parseDocuments())
);
# Output in yaml
%YAML 1.2
%TAG !reproducible! !reproducible
---
!reproducible!sequence [
 &anchor !!str value,
 *anchor ,
 !tag [
  *anchor ,
  !!int 24
 ]
]
...

Classes

YamlDocument Parsing Documents Dumping YAML Documents
A document representing the entire YAML string or a single scalar/collection node within a group of documents in YAML.

Functions

dumpCompactNode<N extends CompactYamlNode>(N node, {required Object? nodeUnpacker(N node)?, ScalarStyle scalarStyle = ScalarStyle.plain}) String Dumping YAML Nodes Dumping YAML Documents
Dumps a node with its properties if any are present. Any CompactYamlNode subtype that is not a Mapping, Sequence or Scalar should define a nodeUnpacker function that prevents the node from being dumped as a Scalar.
dumpYamlDocuments(Iterable<YamlDocument> documents, {ScalarStyle scalarStyle = ScalarStyle.plain}) String Dumping YAML Documents
Dumps a collection of YAML documents with its directives if any are present. The YamlDocument's root node is also dumped with its properties such that all TagShorthands are linked to their respective GlobalTag directives and aliases "compressed" as anchors if possible.