2017-10-20 9 views
1

J'ai une config application.conf:Comment analyser typesafe config avec des objets

usersHasPermissions = [ 
    {"login": "admin", "perms": ["p1", "p2"]}, 
    {"login": "petooh", "perms": ["p2"]}, 
    {"login": "*", "perms": ["p3"]} 
] 

Comment puis-je analyser à Map[String,Set[String], où "login" - clé "perms" - définir?

Je peux le rendre comme json et analyser. Mais je ne voulais pas inclure la bibliothèque json dans le projet. Je pense qu'il ya une solution avec ConfigObject etc.

Répondre

1

Ok, il est simple:

config.getObjectList("usersHasPermissions").asScala.map(o => 
     o.toConfig.getString("login") -> 
     o.toConfig.getStringList("perms").asScala.toSet).toMap