I have many case classes that defines json Read
/Write
/Format
using play-json library. Typical example of such a definition is done using macro
case class Payload(
file: FilePayLoad,
comment: String
)
object Payload {
implicit val format: Format[Payload] = Json.format[Payload]
}
No trouble for writing more specific formats or anything else using the library apis.
Is there any possibility to perform reflection or type analysis on the OReads
implicit defined ? I now little about type level programming, and enough about implicits to retrieve the implicits generated by the macro expansion but I'm working on a self discoverable REST api and I would need to print out the expected JSON format for a given payload case class
Is there any way to reverse the play-json reads definition to print something like this
"format": {
"/payload": {
"/file": {
"type": "FilePayLoad"
"format": {
"/name": {
"type": "String",
"optional": false
},
"/mimeType": {
"type": "String",
"optional": false
},
"/filesize": {
"type": "Double",
"optional": false
},
},
},
"/comment": {
"type": String,
"optional": false
}
}
}
Aucun commentaire:
Enregistrer un commentaire