I've the following model:
case class Person(name: String, age: Int, job: Option[String])
object PersonJsonFormats {
implicit val personFormat = Json.format[Person]
}
Converting a Person object into Json (e.g. with Json.toJson(person)) produces the following Json object.
{
"name": "John",
"age": 10,
"job": "gardener"
}
What should I change in order to produce an object like the following instead?
[
{
"name": "name",
"value" : "John"
},
{
"name": "age",
"value": 10
},
{
"name": "job",
"value": "gardener"
}
]
I know I could write custom Reads and Writes but I want to write something I can apply to every case class