You can use ConfigValue#render to serialize Config
. Config4k helps getting Config
of the class you want to serialize.
data class Person(val name: String, val age: Int)
val person = Person("foo", 20).toConfig("person")
println(person.root().render())
Output:
{
# hardcoded value
"person" : {
# hardcoded value
"age" : 20,
# hardcoded value
"name" : "foo"
}
}