I have been reading in some thread how to map a case class to a Map in scala. Unfortunately none of the answers provided are good enough.
My example would be to have something like:
case class A(a1: String, a2: String, a3: C)
case class C(c1: String, c2: String, c3: D)
case class D(d1: String, d2: String)
Assuming that we have the following instances
val d = D(d1 ="valueForD1", d2 = "valueForD2")
val c = C(c1 ="valueForc1", c2 = "valueForC2", c3 = d)
val a = A(a1 ="valueForA1", a2 = "valueForA2", a3 = c)
I want to transform that case class graph into the following form:
Map("a1" -> "valueForA1", "a2" -> "valueForA2",
"a3" -> Map("c1" -> "valueForC1", "c2" -> "valueForc2",
"c3" -> Map("d1" -> "valueForD1", "d2" -> "valueFord2")))