I receive, in my client, a WSResponse, and use play's deserializeJson
method to extract the data, specified by paths, e.g.
implicit val lsmf: Format[MyData] = (
(__).formatNullable[JsValue] ~
(__ \ "id").format[Int] ~
(__ \ "name").format[String])
(MyData.apply, unlift(MyData.unapply))
The receiving class will look like
case class MyData(
json: JsValue,
id: Int,
name: String) {...}
See, the first member of parsed data is supposed to contain the whole JSON as received.
I don't see how I can accomplish it. If I specify the path as (__)
, this is a bad path, and the parser fails. If I specify the path as (__ \ "")
, the parser looks for a field named ""
, which is obviously missing.
Is there any reasonable solution, beyond just doing parsing manually (with my own hands)?