HttpReadsJson

uk.gov.hmrc.http.HttpReadsJson

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Known subtypes

Members list

Implicits

Implicits

implicit def readJsResult[A : Reads]: HttpReads[JsResult[A]]

Note to read json regardless of error response - can define your own:

Note to read json regardless of error response - can define your own:

 HttpReads[HttpResponse].map(_.json.validate[A])

or custom behaviour - define your own:

HttpReads[HttpResponse].map(response => response.status match {
 case 200   => Right(response.body.json.validate[A])
 case 400   => Right(response.body.json.validate[A])
 case other => Left(s"Invalid status code: $other")
})

Attributes

implicit val readJsValue: HttpReads[JsValue]