This is related to the following question: In scala, how to turn object's values into Map[String, String]?
In fact, I have almost exactly the same problem. However, the solution given in the accepted answer runs around 50x slower than productIterator
(which returns only the values of the fields) when iterating 1000 times on my machine (or manually writing a function to return the list of (key, value) pairs). Is there a reasonably performant and clean way of getting the names of the fields of a case class in Scala? It seems strange to me that the core language would provide a performant reflection-like way of getting the values, but not the field names.