Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Serializing Typesafe Config objects

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

like image 545
questionersam Avatar asked Apr 04 '13 21:04

questionersam


2 Answers

Try this:

config.root().render(ConfigRenderOptions.concise())
like image 128
Sasha O Avatar answered Oct 20 '22 01:10

Sasha O


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))
like image 4
Twistleton Avatar answered Oct 20 '22 01:10

Twistleton