Reputation: 2234
I am trying to create JSON output in this format for C3 charts =>
{
"data1": [220, 240, 270, 250, 280],
"data2": [180, 150, 300, 70, 120],
"data3": [200, 310, 150, 100, 180]
}
I can't use normal Scala classes and jsonFormat2 as the names of the fields are dynamic. I have tried creating a custom RootJsonFormat parser on a simple case class like this =>
case class NamedList[Int](name: String, items: Seq[Int])
But it did not work since the output required by D3 is a JSON object with values inside it, not a JsArray of name, item pairs.
What is the best way of doing this?
Upvotes: 2
Views: 186
Reputation: 2234
I have been told that this is, of course, a:
Map[String, Seq[Int]]
Doh!
Upvotes: 1