Supported Formats
Overview
Helidon Config provides several extension modules that support other configuration formats (parsers) and sources. This document describes how to include them and use them in your project. In each case you need to add module dependencies to your project and, in some cases, write your application accordingly.
Additional Formats
File Type Handling
With each of the parsers described here, your application can either
- explicitly add a parser of the correct implementation to the
Config.Builder, or - rely on Java service loading and the config system’s matching of file types and media types to parsers.
If your application creates a Config.Builder with parser services disabled
(see disableParserServices then that builder will not find
the Java services for the various parsers and so will be unable to match the
file type or media type of sources with the corresponding parser automatically.
So if you want to use automatic type matching with a given builder, do not
invoke Config.Builder.disableParserServices().
YAML
Maven Coordinates
Add the following dependency in your project:
Config YAML Dependency in pom.xml:
<dependency>
<groupId>io.helidon.config</groupId>
<artifactId>helidon-config-yaml</artifactId>
</dependency>
Using the YAML Parser
The YAML parser handles the following media type:
application/x-yaml- YAML format (file type.yaml)
Automatic selection:
HOCON/JSON
The Helidon HOCON config module handles sources in the HOCON and JSON formats.
Maven Coordinates
Add the following dependency in your project:
Config HOCON Dependency in pom.xml:
<dependency>
<groupId>io.helidon.config</groupId>
<artifactId>helidon-config-hocon</artifactId>
</dependency>
Using the HOCON/JSON Parser
The parser handles the following media types:
application/hocon- HOCON format (file type.conf)application/json- JSON format (file type.json)
Automatic selection:
The same module and parser supports file type .json and the media type
application/json.
HOCON parser specified - no file type on source:
Media type specified:
HOCON parser specified because parser services disabled:
Customized HOCON parser:
You can also specify ConfigResolveOptions using the
HoconConfigParser.builder().resolveOptions method.