Convert nested Maps into flat Maps and then expand them back!
Create an instance of the MapFlattener class
MapFlattener mapFlattener = new MapFlattener();
By default, key concatenation uses dots, but you can override this like so
mapFlattener.withSeparator("$");
Now you can start flattening and expanding maps
// flatten it!
Map<String, Object> flattenedMap = mapFlattener.flattenMap(map);
// expand it!
Map<String, Object> map = mapFlattener.expandMap(flattenedMap);
Check out the tests for more examples
You can pull from the central maven repository, just add this to your pom.xml file's <dependencies>
section:
<dependency>
<groupId>com.nathanmyles</groupId>
<artifactId>mapflattener</artifactId>
<version>1.0</version>
</dependency>
This project is licensed under The Apache License, Version 2.0.