Skip to content
zml edited this page Nov 1, 2020 · 5 revisions

Loaders

Loaders handle serializing a ConfigurationNode structure to or from a target, providing load and save operations for any node.

Loaders are created using builders, which allow setting options on a then-immutable configuration loader. Builders accept Callable<BufferedReader>s and Callable<BufferedWriter>s as factories to provide the streams used to read and write configurations.

Implementations

YAML

Format: YAML

Artifact ID: configurate-yaml

Options

  • Indent: How many spaces wide an indentation level should be
  • Node style: Block, Flow, or have the yaml library pick. These flow styles are defined in the YAML spec

Hocon

Format: HOCON

Artifact ID: configurate-hocon

This format is capable of both reading and writing comments that are placed before the node they refer to.

Unfortunately due to limitations in the underlying library, the MapFactory provided by the ConfigurationOptions used in nodes is not respected. This means the output order of nodes is uncertain.

Options

The HoconConfigurationLoader's builder exposes ConfigParseOptions and ConfigRenderOptions from the Hocon library which can be modified as desired.

Jackson

Format: JSON

Artifact ID: configurate-jackson

This is an alternative JSON parser. It supports streaming loading.

Options

  • The JsonFactory is exposed in the builder to set features on
  • indent is configurable
  • the spacing style of field key-value separators is configurable

Gson

Format: JSON

Artifact ID: configurate-gson

Options

  • indent: number of spaces wide an indent should be
  • lenient: whether the parser should handle processes leniently

XML

Format: XML

Artifact ID: configurate-xml

As of Configurate 3.7, this serializer will support round-tripping comments within the document.

Options

  • schema: A javax.xml.validation.Schema instance to validate loaded documents against.
  • defaultTagName: A name for tags for items in a list.
  • indent: The amount of spaces to indent for each level of indentation.
  • writeExplicitType: Explicitly write configurate-type attributes to map and list values.
  • includeXmlDeclaration: Whether to include the XML declaration in written files.