Link Search Menu Expand Document

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"
    }
}

Copyright © 2016-2021 morihiro, since 2021 The Config4k Team. Distributed by an Apache License 2.0.