Converters

SmallRye Config provides a set of additional Converters.

JSON Converter

The JSON Conveter allows you to inject a JsonObject or JsonArray as a ConfigProperty.

Usage

To use the Config Source Injection, add the following to your Maven pom.xml:

<dependency>
    <groupId>io.smallrye.config</groupId>
    <artifactId>smallrye-config-converter-json</artifactId>
    <version>2.4.0</version>
    <scope>runtime</scope>
</dependency>

Example

Use the types JsonObject or JsonArray to inject the ConfigProperty.

@Inject
@ConfigProperty(name = "someJsonArray")
private JsonArray someValue;

@Inject
@ConfigProperty(name = "someJsonObject")
private JsonObject someValue;
someJsonArray=["value1","value2","value3"]
someJsonObject={"foo": "bar", "count":100}

The value of the configuration properties must be valid JSON, or a JsonParsingException is thrown.