Skip to content

Available Formats

A248 edited this page Jul 9, 2023 · 5 revisions

You only need to declare a dependency on the format you choose. There is a transitive dependency on dazzleconf-core.

The core module is space.arim.dazzleconf:dazzleconf-core with module name space.arim.dazzleconf

Gson

Implements the JSON format. Uses Gson

Dependency: space.arim.dazzleconf:dazzleconf-ext-gson

Module name: space.arim.dazzleconf.ext.gson

Details

JSON has no concept of comments and as such there is no easy way to write them. Partial support is provided via GsonOptions#pseudoCommentsSuffix, which enables "commenting" albeit somewhat imperfectly. Other than that, the default Gson instance uses pretty printing and disables html escaping.

Hocon

Implements the HOCON format. Backed by lightbend/config

Dependency: space.arim.dazzleconf:dazzleconf-ext-hocon

Module name: space.arim.dazzleconf.ext.hocon

Details

Hocon has full comment support. However, it has a minor issue with ordering. Written hocon cannot be ordered due to a design bug in the underlying library, which is not expected to be fixed any time soon: https://github.com/lightbend/config/issues/365

SnakeYaml

Implements the YAML format 1.1. Uses SnakeYaml

Dependency: space.arim.dazzleconf:dazzleconf-ext-snakeyaml

Module name: space.arim.dazzleconf.ext.snakeyaml

Compatibility

SnakeYaml versions 1.15-1.33 and 2.0+ are supported.

Details

SnakeYaml has full comment support but it is not enabled by default.

  • If you use SnakeYaml 1.28 or later, CommentMode.fullComments is the best way to write comments.
  • For older SnakeYaml versions, CommentMode.alternateWriter enables writing comments though the alternate writer which does not use SnakeYaml.
  • The default mode is CommentMode.headerOnly which writes the top level comment header but nothing else.

The CommentMode has to be set on the SnakeYamlOptions in order for it to take effect.

Clone this wiki locally