I have a custom data type in Scala:
case class GPID(value: Int) {
// ... other stuff ...
implicit val writesGPID = new Writes[GPID] {
def writes(g: GPID): JsValue = {
Json.obj(
"GPID" -> g.value
)
}
}
implicit val reads: Reads[GPID] = (
(__ \ "GPID").read[Int]
).map(GPID(_))
}
As you can see, it has a reads/writes method, but this result in output like this:
"id":{"GPID":1000}
But, we just want it to serialize/deserialize like a regular Int:
"id":1000
I've been trying to figure out how to rewrite the reads/writes but am not having much luck... Any advice would be appreciated!
Thank you.