2

I am trying to map the case class to the JSON Using the akka Http

 import akka.http.scaladsl.model.StatusCodes
 import akka.http.scaladsl.server.Directives._
 import akka.http.scaladsl.server.PathMatchers.IntNumber
 import de.heikoseeberger.akkahttpcirce.CirceSupport
 import io.circe.generic.auto._
 import io.circe.syntax._

case class JobEntity(id: Option[Long] = None, name: String, description: String) 

Then for Routing

post {
  entity(as[JobEntity]) { jobEntity: JobEntity =>
    complete(createJob(jobEntity).map(_.asJson))
  }
}

This maps my JSON to the JobEntity but problem lies with another use case where my case class is

 case class JobEntityNew(id: Option[Long] = None, name: String, description: String, jsonRaw :java.sql.blob) 

The JsonRaw needs to pass the json as blob for which I am struggling as to how do I map whole json to the case class apart from other arguments .

Arnout Engelen
  • 6,709
  • 1
  • 25
  • 36
Vishal
  • 1,442
  • 3
  • 29
  • 48
  • For `JobEntity` you're auto-generating the JSON conversion using `io.circe.generic.auto._`. Because you want to do something 'custom' for `JobEntityNew`, instead of relying on the auto-generated conversion you'll probably have to investigate how to use circe to write your own converter that does what you want. – Arnout Engelen May 16 '17 at 14:38

0 Answers0