Hocon

Allows deserialization of Config object from popular Lightbend/config library into Kotlin objects.

Config object represents "Human-Optimized Config Object Notation" — https://github.com/lightbend/config#using-hocon-the-json-superset.

Duration objects are encoded/decoded using "HOCON duration format" - Duration format[https://github.com/lightbend/config/blob/main/HOCON.md#duration-format] [Duration] objects encoded using time unit short names: d, h, m, s, ms, us, ns. Encoding use the largest time unit. Example: 120.seconds -> 2 m 121.seconds -> 121 s 120.minutes -> 2 h 122.minutes -> 122 m 24.hours -> 1 d All restrictions on the maximum and minimum duration are specified in Duration.

It is also possible to encode and decode java.time.Duration and com.typesafe.config.ConfigMemorySize with provided serializers: JavaDurationSerializer and ConfigMemorySizeSerializer. Because these types are not @Serializable by default, one has to apply these serializers manually — either via @Serializable(with=...) / @file:UseSerializers or using Contextual and SerializersModule mechanisms.

Parameters

useConfigNamingConvention

switches naming resolution to config naming convention (hyphen separated).

serializersModule

A SerializersModule which should contain registered serializers for Contextual and Polymorphic serialization, if you have any.

Inheritors

Types

Link copied to clipboard

The default instance of Hocon parser.

Properties

Link copied to clipboard

Functions

Link copied to clipboard

Decodes the given config into a value of type T using the given serializer.

Link copied to clipboard
inline fun <T> Hocon.decodeFromConfig(config: Config): T

Decodes the given config into a value of type T using a deserializer retrieved from the reified type parameter.

Link copied to clipboard

Encodes the given value into a Config using the given serializer.

Link copied to clipboard
inline fun <T> Hocon.encodeToConfig(value: T): Config

Encodes the given value of type T into a Config using a serializer retrieved from the reified type parameter.