Link Search Menu Expand Document

Typesafe Config’s class ConfigRenderOptions is the argument of ConfigValue#render.

// If setJson(false) is called, ConfigValue.render returns HOCON
data class Person(val name: String, val age: Int)

val person = Person("foo", 20).toConfig("person")
val options = ConfigRenderOptions.defaults().setJson(false)
println(person.root().render(options))

Output:

    # hardcoded value
person {
    # hardcoded value
    age=20
    # hardcoded value
    name=foo
}
// setOriginComments(false) removes comments
data class Person(val name: String, val age: Int)

val person = Person("foo", 20).toConfig("person")
val options =
    ConfigRenderOptions.defaults()
        .setJson(false)
        .setOriginComments(false)
println(person.root().render(options))

Output:

person {
    age=20
    name=foo
}

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