Search code examples
javayaml

How to read out of a yml map<string, Map<string, string>> structure with cfg4j?


I have the following yml file

test-files:
  testSets:
    smoke:
      - "a" : "b"

    video:
      - "c" : "d"

I am trying to read this out using cfg4j but I don't seem to get the interface right. What I want to get is a map with all the testSets with all the data for that set inside it.

So e.g. if I have the following map construction:

map<String, Map<String, String>>

I want to have in the first string the value smoke, in the second one a and the last one b etc.

The interface that I already tried to us for this is:

interface TestSets{
 Map<String, Map<String, String>> testSets;
}

But this doesn't work. Has someone any idea about how to read this out using the cfg4j lib?


Solution

  • CFG4J uses type-parser for deserialization. Non-nested maps can be expressed as strings: Example here:

    Unfortunately, nested Maps are currently not supported in CFG4J (issue).