unmarshaller的哪些组件可以将http实体解组为Map [String,AnyRef]

时间:2016-06-13 05:19:03

标签: akka-http

我努力创建一个可以从httpEntity中创建Map [String,AnyRef]的unmarshaller,以便流动的路径定义可以正常工作

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

  }
}}

我在这里阅读了关于编组的akka​​文档以及一些教程http://malaw.ski/2016/04/10/hakk-the-planet-implementing-akka-http-marshallers/。但我仍然无法弄清楚如何完成它。

所以我的问题是:

  1. unmarshaller的一些组成部分是什么?

  2. 如何创建这些组件并将它们放在一起?

1 个答案:

答案 0 :(得分:3)

它取决于序列化数据的格式。

例如,如果你选择Json。您需要使用public static int sum(ArrayList<Integer> list) { return list.stream().mapToInt(i->i).sum(); } write方法创建隐式对象以进行序列化和反序列化。

示例:

read