Reputation: 1700
I'm trying to access a Grails property that I've created using dynamic logic to determine which property file to use.
This is the simplified example:
String pathToKey = "Level1.Level2.Level3"
assert config.rootProperties[pathToKey].key ## Returns empty key value assert config.rootProperties.Level1.Level2.Level3.key ## Returns proper key value
What is the proper way to create a multie level/object configuration file and dynamically access the key?
Upvotes: 1
Views: 266
Reputation: 1700
I found the solution I was looking for:
String pathAndKey = "rootProperties.Level1.Level2.Level3.key"
String value = config.flatten().getProperty(pathAndKey)
Upvotes: 1