Given the following Json array:
{
"success": true,
"data": [
{
"id": 594,
"stage_id": 15,
"title": "test deal",
"value": 0,
"currency": "EUR",
"add_time": "2014-03-18 17:45:51",
"update_time": "2014-03-24 13:30:27",
"stage_change_time": "2014-03-24 13:30:27",
"active": true,
"deleted": false,
"status": "open",
"expected_close_date": null,
"stage_order_nr": 1,
"person_name": "test"
},
{
"id": 601,
"stage_id": 15,
"title": "test deal2 deal",
"value": 0,
"currency": "EUR",
"add_time": "2014-03-24 14:11:00",
"update_time": "2014-03-24 14:11:00",
"stage_change_time": "2014-03-24 14:11:00",
"active": true,
"deleted": false,
"status": "open",
"expected_close_date": null,
"stage_order_nr": 1,
"person_name": "test deal2"
}
],
"additional_data": {
"pagination": {
"start": 0,
"limit": 100,
"more_items_in_collection": false
}
}
}
I want to get a List of deals out of it and I am trying it like so
case class Deal(id: Long, stage_id: Long)
def getAllDeals(): List [Deal] = {
var holder : WSRequestHolder = WS.url(PipeDriveApiBaseUrl + "/deals")
val complexHolder: WSRequestHolder = holder.withQueryString("filter_id" -> "9", "api_token" -> SalesManagerApiKey)
val futureResponse: Future[Response] = complexHolder.get()
implicit val dealReader = Json.reads[List[Deal]]
val futureJson: Future[List[Deal]] = futureResponse.map(
response => (response.json \ "data").validate[List[Deal]].get
)
I get the exception No unapply function found
which is related to the implicit reads value. But commenting it out, I will get No Json deserializer found for type List[models.Deal]. Try to implement an implicit Reads or Format for this type.
I couldn't solve the problem with these answers here and here. What do I miss or misunderstand?