NimYAML Home Testing Ground Docs: Overview Serialization Modules NimYAML 2.x Source on GitHub

Module yaml/dumping

The dumping API enables you to dump native Nim values as YAML character stream. Along with the loading API, this forms the highest-level API of NimYAML.

Imports

parser, presenter, native, internal, taglib

Types

Dumper = object
  presentation*: PresentationOptions
  serialization*: SerializationOptions
Holds configuration for dumping Nim values. Default initialization yields the style that can be set via setDefaultStyle.

Procs

proc blockOnlyDumper(): Dumper {....raises: [], tags: [], forbids: [].}
proc canonicalDumper(): Dumper {....deprecated: "renamed to explanatoryDumper",
                                 raises: [], tags: [], forbids: [].}
proc dump[K](dumper: Dumper; value: K): string {.hint[XCannotRaiseY]: false, ...raises: [
    YamlPresenterJsonError, YamlPresenterOutputError, YamlSerializationError].}
Dump a Nim value as YAML into a string.
proc dump[K](dumper: Dumper; value: K; target: Stream) {....raises: [
    YamlPresenterJsonError, YamlPresenterOutputError, YamlSerializationError].}
Dump a Nim value as YAML into the given stream.
proc explanatoryDumper(): Dumper {....raises: [], tags: [], forbids: [].}
proc jsonDumper(): Dumper {....raises: [], tags: [], forbids: [].}
proc minimalDumper(): Dumper {....raises: [], tags: [], forbids: [].}
proc setBlockOnlyStyle(dumper: var Dumper) {....raises: [], tags: [], forbids: [].}
Output preset. Uses block style exclusively.
proc setCanonicalStyle(dumper: var Dumper) {.
    ...deprecated: "renamed to setExplanatoryStyle", raises: [], tags: [],
    forbids: [].}
proc setDefaultStyle(dumper: var Dumper) {....raises: [], tags: [], forbids: [].}
Output preset. Uses block style by default, but flow style for collections that only contain scalar values.
proc setExplanatoryStyle(dumper: var Dumper) {....raises: [], tags: [], forbids: [].}
Output preset. Generates specific tags for all nodes, uses flow style, quotes all string scalars. Enables the !n! tag shorthand.
proc setJsonStyle(dumper: var Dumper) {....raises: [], tags: [], forbids: [].}
Output preset. Uses flow style, omits tags, anchors and all other non-JSON entities, formats all scalars as corresponding JSON values.
proc setMinimalStyle(dumper: var Dumper) {....raises: [], tags: [], forbids: [].}
Output preset. Tries to output single line flow-only output.
proc transform(dumper: Dumper; input: Stream | string;
               resolveToCoreYamlTags: bool = false): string {....raises: [IOError,
    OSError, YamlParserError, YamlPresenterJsonError, YamlPresenterOutputError].}
Parse input as YAML character stream and then dump it using the given presentation options. Returns the resulting string. If resolveToCoreYamlTags is true, non-specific tags will be replaced by specific tags according to the YAML core schema.
proc transform(dumper: Dumper; input: Stream | string; output: Stream;
               resolveToCoreYamlTags: bool = false) {....raises: [IOError, OSError,
    YamlParserError, YamlPresenterJsonError, YamlPresenterOutputError].}
Parse input as YAML character stream and then dump it to output using the given presentation options. If resolveToCoreYamlTags is true, non-specific tags will be replaced by specific tags according to the YAML core schema.