ConfigMemorySizeSerializer
Serializer for ConfigMemorySize. All possible Hocon size formats [https://github.com/lightbend/config/blob/main/HOCON.md#size-in-bytes-format] are accepted for decoding. During encoding, the serializer emits values using powers of two: byte, KiB, MiB, GiB, TiB, PiB, EiB, ZiB, YiB. Encoding uses the largest possible integer value. Example: 1024 byte -> 1 KiB; 1024 KiB -> 1 MiB; 1025 KiB -> 1025 KiB. Usage example:
@Serializable
data class ConfigMemory(
@Serializable(ConfigMemorySizeSerializer::class)
val size: ConfigMemorySize
)
val config = ConfigFactory.parseString("size = 1 MiB")
val configMemory = Hocon.decodeFromConfig(ConfigMemory.serializer(), config)
val newConfig = Hocon.encodeToConfig(ConfigMemory.serializer(), configMemory)
Content copied to clipboard