سؤال

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