문제

I'd like to persist a Config object (https://github.com/typesafehub/config) as a serialized string(maybe JSON ??) and read it back when required. However, I didnt find any API on the Config api docs that supports. Any help on this is appreciated.

I tried

config.toString

but the result looks like

Config(SimpleConfigObject({...data}))

도움이 되었습니까?

해결책

Try this:

config.root().render(ConfigRenderOptions.concise())

다른 팁

Of course you can also adjust a few parameters, for example:

val renderOptions = ConfigRenderOptions
  .defaults()
  .setOriginComments(false)
  .setComments(false)
  .setFormatted(true)

println(config.root().render(renderOptions))
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top