Java Akka http 路由发布方法无法解组嵌套实体对象

问题描述 投票:0回答:0

我正在尝试在 Post 请求正文中发送嵌套 json 以调用 akkhttp 路由,但出现异常, 无法将 JSON 解组为 Campaign

有人请帮我解决这个问题。

下面是代码

concat(
            post(() ->  pathPrefix(PathMatchers.segment(ACCOUNTS_SEGMENT).slash(PathMatchers.segment()), (accountId) ->
                  path(PathMatchers.segment(JOBS_SEGMENT).slash(PathMatchers.uuidSegment())  , (jobId) -> {
                              **return entity(Jackson.unmarshaller(Campaign.class), campaign -> {**
                                  System.out.println("###############"+campaign.getName());
                                  CompletionStage<Done> futureSaved = executeCampaignProcess(jobId.toString(), accountId);
                              return onSuccess(futureSaved, done ->
                                      complete(StatusCodes.ACCEPTED, ACCEPTED_EXECUTE_CAMPAIGN_REQUEST)
                              );
                          });
              }
              )))

请求体中嵌套的json如下

{
  "id" : "2d2cee47-40c9-4ebe-80bb-f8a38e6379f9",
  "name" : "DDDAmol",
  "description" : "",
  "type" : "FINITE",
  "senderDisplayName" : "",
  "senderAddress" : "",
  "dialingOrder" : [ "PRIORITY", "RETRY", "REGULAR" ],
  "finishType" : "FINISH_AFTER",
  "finishTime" : null,
  "finishAfter" : 0,
  "checkTimeBasedFinishCriteria" : false,
  "createdOn" : [ 2023, 1, 31, 8, 12, 40, 32309000 ],
  "updatedOn" : [ 2023, 2, 14, 14, 11, 4, 758967300 ],
  "lastExecutedOn" : [ 2023, 2, 18, 13, 51, 28, 821000000 ],
  "contactList" : "CD_06_SMS_QUEUED_DELAYED",
  "rule" : null,
  "strategy" : {
    "id" : "a41d8895-7a67-4cce-a39b-5a6ee5e8b4a9",
    "name" : "Simple",
    "type" : "SMS",
    "description" : "",
    "smsText" : "Hello",
    "smsPace" : 40,
    "smsPaceTimeUnit" : "SECOND",
    "createdOn" : [ 2023, 1, 31, 8, 12, 15, 209992700 ],
    "updatedOn" : [ 2023, 1, 31, 8, 12, 15, 209992700 ]
  }
}
java akka-http
© www.soinside.com 2019 - 2024. All rights reserved.