Flatten nested maps and JSON to dot-notation keys and unflatten back
implementation com.philiprehberger:flatten-jsonFlatten nested maps to dot-notation keys and unflatten back.
implementation("com.philiprehberger:flatten-json:0.1.4")
<dependency>
<groupId>com.philiprehberger</groupId>
<artifactId>flatten-json</artifactId>
<version>0.1.4</version>
</dependency>
import com.philiprehberger.flattenjson.*
val nested = mapOf("user" to mapOf("name" to "Alice", "address" to mapOf("city" to "Berlin")))
val flat = flatten(nested)
// {"user.name": "Alice", "user.address.city": "Berlin"}
val restored = unflatten(flat) // back to nested
| Function / Class | Description |
|---|---|
flatten(map, separator, prefix, maxDepth) | Flatten nested map to dot-notation keys |
unflatten(map, separator) | Restore nested structure from flat map |
./gradlew test # Run tests
./gradlew build # Build JAR
If you find this project useful: