Convert Nested Case Classes to Nested Maps in Scala
问题 I have two nested case classes: case class InnerClass(param1: String, param2: String) case class OuterClass(myInt: Int, myInner: InnerClass) val x = OuterClass(11, InnerClass("hello", "world")) Which I want to convert to nested Maps of type Map[String,Any] so that I get something like this: Map(myInt -> 11, myInner -> Map(param1 -> hello, param2 -> world)) Of course, the solution should be generic and work for any case class. Note: This discussion gave a good answer on how to map a single