Some more information.
In IntelliJ, if I do a Cmd+Sht+P on the Unmarshal method, I get for the unmarshal() <https://lh3.googleusercontent.com/-dgEy6xKx5vA/V7RqWOFbYvI/AAAAAAAACPE/d1WvjnkWdxsMz71ZK-OZ_u_9TmTp8XfvACLcB/s1600/Capture%2Bd%25E2%2580%2599e%25CC%2581cran%2B2016-08-17%2Ba%25CC%2580%2B15.41.30.png> I get for the unmarshal().to[] <https://lh3.googleusercontent.com/-UfJiYD8iacI/V7RptPc2K9I/AAAAAAAACPA/H0Hi_h-fd9sM32Bjl62LexUkLdWaGRYhwCLcB/s1600/Capture%2Bd%25E2%2580%2599e%25CC%2581cran%2B2016-08-17%2Ba%25CC%2580%2B15.41.10.png> I hope it helps :) Thx Le mercredi 17 août 2016 15:37:38 UTC+2, hervé DARRITCHON a écrit : > > Hi !! > > One more subject about this topic :( > I looked deeply in this group, found some post and solutions > (materializer, add SprayJsonSupport, read Konrad's post, ...) but nothing > work ! > > Moreover, I have several class that parsed some Json et 2 of them works et > with the last I have this pb :( > > This Actor class is used to translate a JwtToken into an object. > > Interpreter.scala > > import java.sql.Timestamp > > import akka.actor.{Actor, ActorLogging, Props} > import akka.http.scaladsl.marshallers.sprayjson.SprayJsonSupport > import akka.http.scaladsl.unmarshalling.Unmarshal > import akka.stream.{ActorMaterializer, ActorMaterializerSettings} > import com.orange.spectre.model.{JwtToken, JwtTokenHeader, JwtTokenPayload, > RawJwtToken} > import spray.json.DefaultJsonProtocol > > import scala.concurrent.Future > > trait TokenPartsJsonSupport extends SprayJsonSupport with DefaultJsonProtocol > { > implicit val jwtTokenHeaderFormat = jsonFormat2(JwtTokenHeader) > implicit val jwtTokenPayloadFormat = jsonFormat5(JwtTokenPayload) > } > > case class StartInterpreterMessage() > > case class StopInterpreterMessage() > > object Interpreter { > > def props(token: RawJwtToken): Props = Props(new Interpreter(token)) > } > > /** > * Created by Hervé Darritchon on 17/08/2016. > * > */ > class Interpreter(rawToken: RawJwtToken) extends Actor with ActorLogging with > TokenPartsJsonSupport { > > // Dispatcher is used as implicit for all the future call methods in this > class > import context.dispatcher > > final implicit val materializer: ActorMaterializer = > ActorMaterializer(ActorMaterializerSettings(context.system)) > > > def translate(rawToken: RawJwtToken): Option[JwtToken] = { > val parts: Array[String] = rawToken.accessToken.split(".") > > val decodedHeader: String = > java.util.Base64.getDecoder.decode(parts(0)).toString > val decodedPayload: String = > java.util.Base64.getDecoder.decode(parts(1)).toString > > val payload: Future[Either[String, JwtTokenPayload]] = > Unmarshal(decodedPayload).to[JwtTokenPayload].map(Right(_)) > > } > > private val token: Option[JwtToken] = translate(rawToken) > > > > JwtTokenPayload.scala > > * Created by Hervé Darritchon on 30/05/2016. > * > */ > case class JwtTokenPayload(iat: Long, iss: String, sub: String, exp: Long, > user_id: String) > > > When I compile my program, I get a compile error : > [error] .../actors/Interpreter.scala:54: could not find implicit value for > parameter um: > akka.http.scaladsl.unmarshalling.Unmarshaller[String,model.JwtTokenPayload] > [error] val payload: Future[Either[String, JwtTokenPayload]] = > Unmarshal(decodedPayload).to[JwtTokenPayload].map(Right(_)) > [error] > ^ > [error] one error found > [error] (compile:compile) Compilation failed > [error] Total time: 0 s, completed 17 août 2016 15:14:56 > > I don't understand why, sorry :( > > I have my implicit Format, I have my ec, my materializer. It should work > but it doesn't. I have missed something I gues but can't find what :) > > Thanks ! > > -- >>>>>>>>>> Read the docs: http://akka.io/docs/ >>>>>>>>>> Check the FAQ: >>>>>>>>>> http://doc.akka.io/docs/akka/current/additional/faq.html >>>>>>>>>> Search the archives: https://groups.google.com/group/akka-user --- You received this message because you are subscribed to the Google Groups "Akka User List" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/akka-user. For more options, visit https://groups.google.com/d/optout.
