5

I am trying to create Akka Http REST post endpoint mapping the JSON objects to the case class defined

import io.circe.Decoder, io.circe.generic.auto._

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

The JSON is of type

{
 "id": "124",
 "name": "MYJOB",
 "description": "Test Job"
}

Now I want to map whole JSON to the 'json_data' as blob defined in the case class

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

I understand .map(_.asJson) would map the json to the JobEntity, Correct me if Its not like this
How do I map the whole JSON to the json_data.

Vishal
  • 1,442
  • 3
  • 29
  • 48

1 Answers1

3

You need to import Circe support methods. See the example . And you need to add dependency de.heikoseeberger % akka-http-circe.

nader.h
  • 506
  • 2
  • 17
simpadjo
  • 3,947
  • 1
  • 13
  • 38