with Play JSON:
case class CertFile(name: String, path: String, extension: String)
case class Certificate(certType: String, certFile: CertFile)
implicit val certFile: Reads[CertFile] = (
(JsPath \ "name").read[String] and
(JsPath \ "path").read[String] and
(JsPath \ "extension").read[String]
) (CertFile.apply _)
implicit val cert: Reads[Certificate] = (
(JsPath \ "type").read[String] and
(JsPath \ "file").read[CertFile]
) (Certificate.apply _)
and you can use this way:
val json =
"""{ "certificates": [{"type": "abc","file": {"name": "xyz","path":"/usr/local","extension": "csv"}} , {"type": "xyz","file": {"name": "xyz","path": "/usr/local","extension": "csv"}} , {"type": "nmo","file": {"name": "xyz","path": "/usr/local","extension": "csv"}}] }"""
val jsonValue = Json.parse(json)
val list = (jsonValue \ "certificates").as[List[Certificate]]