I have nested map as below:
val x: Map[String, Any] =
Map("a" -> "apple", "b" -> "ball", "c" -> Map("x" -> "cat", "y" -> 12))
and I want to convert it into:
Map("a" -> "apple", "b" -> "ball", "x" -> "cat", "y" -> 12)
However, if I try to invoke flatten to x then I get exception.
x.flatten
Error:(40, 14) No implicit view available from (String, Any) => scala.collection.GenTraversableOnce[B].
println(mx.flatten)
Error:(40, 14) not enough arguments for method flatten: (implicit asTraversable: ((String, Any)) => scala.collection.GenTraversableOnce[B])scala.collection.immutable.Iterable[B].
Unspecified value parameter asTraversable.
println(x.flatten)
So, how can I provide implicit view in order to flatten the above map?
xis already a key on the outer map?