I've managed to convert my code to using the reads/writes implicits, but in one case I require a format implicit which does not seem to work. I am declaring the implicit val inside the object of the case class like so (which works for reads, or writes):
import play.api.libs.json._
import play.api.libs.json.Json
import play.api.libs.json.util._
import play.api.libs.json.Writes._
import play.api.libs.json.Reads._
import play.api.libs.json.Format._
case class AccessTokenError(
error: String,
error_description: String,
error_uri: String
)
object AccessTokenError {
implicit val format = Json.format[AccessTokenError]
}
but get the following error:
[error] /Users/alex/github/meep/app/dtos/oauth/AccessTokenError.scala:17: type mismatch;
[error] found : dtos.oauth.AccessTokenError.type
[error] required: (String, String, String) => dtos.oauth.AccessTokenError
[error] Note: implicit value format is not applicable here because it comes after the application point and it lacks an explicit result type
[error] implicit val format = Json.format[AccessTokenError]
[error] ^
Also another issue I had was where I had a custom apply function in my object, the writes macro did not work and I had to remove it.. I would expect the macro to work with custom apply functions, so I guess this might not have been tested yet?
[error] exception during macro expansion:
[error] scala.ScalaReflectionException: value apply encapsulates multiple overloaded alternatives and cannot be treated as a method. Consider invoking `<offending symbol>.asTerm.alternatives` and manually picking the required method
[error] at scala.reflect.api.Symbols$SymbolApi$class.asMethod(Symbols.scala:247)
[error] at scala.reflect.internal.Symbols$SymbolContextApiImpl.asMethod(Symbols.scala:73)
[error] at play.api.libs.json.Json$.writesImpl(Json.scala:433)
[error] /Users/alex/github/meep/app/controllers/Files.scala:56: No Json deserializer found for type dtos.GridFSFileDTO. Try to implement an implicit Writes or Format for this type.
It would be appreciated if you could look into the format issue and if necessary I can create a sample project which produces the error.
Thanks for all the great work!