This structure can be represented by Map<String, Map<String, Any>> . Kotlin's code for creating this type:
val fromDb: Map<String, Map<String, Any>> = mapOf( "Key1" to mapOf("KeyA" to "Value", "KeyB" to "Value"), "Key2" to mapOf("KeyC" to "Value", "KeyD" to "Value") )
In Java, starting with JDK 9, this can be expressed as follows:
Map<String, Map<String, Object>> fromDb = Map.of( "Key1", Map.of("KeyA", "Value", "KeyB", "Value"), "Key2", Map.of("KeyC", "Value", "KeyD", "Value") );
Note that the Any type in Kotlin basically matches the Object in Java.
s1m0nw1
source share