Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TypeSafeConfig and PureConfig - load a Map[String, Any] value from config

I'm trying to load up a Map[String, Any] from the config file. It's currently written like this

map-name {
   stringValue = "firstValue"
   intValue = 1
   booleanValue = true
  }

Pureconfig is having trouble reading this config as a Map[String, Any]. It only works if replace Any with some strict type but I want more flexibility than this.

Is there any way around this?

like image 814
suleydaman Avatar asked Nov 28 '25 20:11

suleydaman


1 Answers

Is there any way around this?

Yes there is. You can use this type: Map[String, ConfigValue]

ConfigValue from its Scala Doc:

An immutable value, following the JSON type schema.

But then you can use ConfigObject instead of Map[String, ConfigValue], as this is the same thing.

You can handle this now like a JSON-Object structure.

Here are some examples: java-api-usage-examples.

like image 92
pme Avatar answered Dec 01 '25 09:12

pme