Author Topic: Scala error while resolving overloaded methods  (Read 672 times)

Offline broun

  • Newbie
  • *
  • Posts: 1
  • Karma: 0
    • View Profile
Scala error while resolving overloaded methods
« on: September 19, 2015, 05:31:17 PM »
Hi scalaers,

Im getting the following error while trying to use the Play `s Json library for de-serializing json string. I understand it is failing to resolve to an overloaded method but Im failing to understand why?

Error:(45, 50) overloaded method value apply with alternatives:
  (f: B => (String, String, com.model.ESource.Value, com.model.Address, java.time.ZonedDateTime, java.time.ZonedDateTime))(implicit fu: play.api.libs.functional.ContravariantFunctor[play.api.libs.json.Reads])play.api.libs.json.Reads <and>
  (f: (String, String, com.model.ESource.Value, com.model.Address, java.time.ZonedDateTime, java.time.ZonedDateTime) => B)(implicit fu: play.api.libs.functional.Functor[play.api.libs.json.Reads])play.api.libs.json.Reads
 cannot be applied to (com.model.Event.type)
      (JsPath \ "startTime").read[ZonedDateTime] and

the above exception is caused by ( Im using Play's JSON library - import play.api.libs ):

  def fromJsonString(jsonString: String): Event = {
    val jv = Json.parse(jsonString)

Im not even sure what the syntax actually means? I see that => is used for anonymous functions where the right side are arguments and left would be the function expression. But Im not sure what the B in the exception refers to and how the 2 method signatures are to be interpreted? Appreciate any help here, thanks !!