0

I struggled to create a unmarshaller that can make a Map[String, AnyRef] out of an httpEntity, So that the flowing route definition will work

path("cedt" / "processRow3") {
post {
  entity(as[java.util.Map[String, AnyRef]]) {
    rowobj => rowProcessorActor ! rowobj
      complete {
        "sent to backend actor"
      }

  }
}}

I read the akka document on marshalling and also some tutorial here http://malaw.ski/2016/04/10/hakk-the-planet-implementing-akka-http-marshallers/. But still I can't figure out how to get it done.

So My question is:

  1. What are some of the components of an unmarshaller?

  2. How to create those components and put them together?

Origin Jing
  • 109
  • 12

1 Answers1

3

It depends which format you want for serialized data.

For example, if you choose Json. You need to create implicit object with write and read methods for serializing and deserializing.

example:

implicit object MapJsonFormat extends JsonFormat[Map[String, AnyRef]] {

    def write(m: Map[String, AnyRef]): JsValue = 

    def read(value: JsValue): Map[String, AnyRef]  = 
}