I have some nested maps like:
val map1 = Map("key1"->1, "key2"->Map("x"->List(1,2)))
val map2 = Map("key3"->3, "key2"->Map("y"->List(3,4)))
And I want to merge them to obtain the result map like;
val res = Map("key1"->1, "key2"->Map("x"->List(1,2), "y"->List(3,4)), "key3"->3)
So nested maps should also be merged. The type of the maps and nested maps can be assumed as Map[String, Any]. It's considered an exception if the two maps have conflict keys (eg. values of the same key are different, except that the value is a nested map).
Is there some elegant solution to this? Thanks!