Java Spring集成JSON逃逸问题

Java Spring集成JSON逃逸问题,java,json,spring,spring-integration,dsl,Java,Json,Spring,Spring Integration,Dsl,我在下面列出了spring集成流程,以协调2个api,聚合结果并以列表的形式返回。工作流程按预期工作,但响应是JSON转义的。我想写消息转换器,但不确定这是否正确,这里有什么帮助吗 Respone JSON: [ "{\"primaryCardNumber\":\"0002345235352345\"", "\"accountStatus\":\"A\"", "\"primaryCardSequence\":\"1234\"", "\"secondaryCardsNumb

我在下面列出了spring集成流程,以协调2个api,聚合结果并以列表的形式返回。工作流程按预期工作,但响应是JSON转义的。我想写消息转换器,但不确定这是否正确,这里有什么帮助吗

Respone JSON:

[
   "{\"primaryCardNumber\":\"0002345235352345\"",
   "\"accountStatus\":\"A\"",
   "\"primaryCardSequence\":\"1234\"",
   "\"secondaryCardsNumber\":\"4\"",
   "\"additionalCardsNumber\":\"1\"",
   "\"lastPaymentDate\":\"2016-08-18\"",
   "\"billingCurrencyCode\":\"GBP\"}",
   "{\"primaryCardNumber\":\"00064545108761239\"",
   "\"accountStatus\":\"A\"",
   "\"primaryCardSequence\":\"4221\"",
   "\"secondaryCardsNumber\":\"1\"",
   "\"additionalCardsNumber\":\"0\"",
   "\"lastPaymentDate\":\"2015-12-01\"",
   "\"billingCurrencyCode\":\"GBP\"}"
]   
代码:

@MessagingGateway
公共接口帐户列表{
@网关(requestChannel=“accountListFlow.input”)
列表accountListFlow(字符串customerId);
}
@豆子
公共集成流accountListFlow(){
返回流->流.publishSubscribeChannel(s->s.applySequence(true)
.订阅(f->f
.EnrichHeader(h->h.header(“X-CUST-IP-Id”、“145.26.54.24”))
.handle(Http.outboundGateway(“http://get-customers-product-holdings-gb-hbeu-v3-v3-cert.cf.wgdc-drn-01.cloud.uk/api/customers/{customer}/productholdings?categoryCode=cc、cbs、sd”)
.httpMethod(httpMethod.GET)
.mappedRequestHeaders(“X-CUST-IP-Id”)
.expectedResponseType(String.class)
.URI变量(“客户”、“有效负载”)
.有效载荷(真)
.channel(“aggregateAccount.input”)
.订阅(f->f
.EnrichHeader(h->h.header(“X-CUST-IP-Id”、“145.26.54.24”))
.handle(Http.outboundGateway(“http://get-customers-product-holdings-gb-hbeu-v3-v3-cert.cf.wgdc-drn-01.cloud.uk/api/customers/{客户}/余额)
.httpMethod(httpMethod.GET)
.mappedRequestHeaders(“X-CUST-IP-Id”)
.expectedResponseType(String.class)
.URI变量(“客户”、“有效负载”)
.有效载荷(真)
.channel(“aggregateAccount.input”)
);
}           
@豆子
公共IntegrationFlow aggregateAccount(){
回流->流量
.aggregate(a->a.expireGroupsUponCompletion(真)
.outputProcessor(g->g.getMessages()
.stream()
.filter(m->m.getPayload()!=null)
.map(message->message.getPayload().toString())
.collect(collector.joining(“,”));
}

请提供更多信息!您在哪里看到该结果?您如何确定自己做错了什么?服务的这两个结果看起来如何?它不是“转义的”。您有一个带有单个字符串的数组,该数组本身恰好是json数据。该流从返回json的Spring REST控制器中触发,上面的结果如调用URI时从chrome或SOAPUI中看到的。将两个API的响应记录到控制台上看起来没有json escape。请注意,我的REST控制器是列表,在那之前聚合器的结果是相同的。希望这有帮助。@cricket_007,如果我从列表更改为字符串,我不会得到聚合消息,而只得到第一条消息。`@RequestMapping(value=“/account/List/{customerId}”,method=RequestMethod.get,products={MediaType.APPLICATION_JSON_VALUE}@ResponseBody公共字符串accountList(@PathVariable String customerId){return accountListGatewayGateway.accountListFlow(customerId);}`
    @MessagingGateway
    public interface AccountList {

       @Gateway(requestChannel = "accountListFlow.input")
       List<String> accountListFlow(String customerId);
    }

     @Bean
     public IntegrationFlow accountListFlow() {
            return flow -> flow.publishSubscribeChannel(s -> s.applySequence(true)
                                    .subscribe(f -> f
                                               .enrichHeaders(h -> h.header("X-CUST-IP-Id","145.26.54.24"))      
            .handle(Http.outboundGateway("http://get-customers-product-holdings-gb-hbeu-v3-v3-cert.cf.wgdc-drn-01.cloud.uk/api/customers/{customer}/product-holdings?categoryCode=cc,cbs,sd")
                .httpMethod(HttpMethod.GET)
                .mappedRequestHeaders("X-CUST-IP-Id")
                .expectedResponseType(String.class)
                .uriVariable("customer", "payload")
                .extractPayload(true))
            .channel("aggregateAccount.input")
.subscribe(f -> f
                                           .enrichHeaders(h -> h.header("X-CUST-IP-Id","145.26.54.24"))      
        .handle(Http.outboundGateway("http://get-customers-product-holdings-gb-hbeu-v3-v3-cert.cf.wgdc-drn-01.cloud.uk/api/customers/{customer}/balances")
            .httpMethod(HttpMethod.GET)
            .mappedRequestHeaders("X-CUST-IP-Id")
            .expectedResponseType(String.class)
            .uriVariable("customer", "payload")
            .extractPayload(true))
        .channel("aggregateAccount.input")
);
}           
      @Bean
      public IntegrationFlow aggregateAccount() {
         return flow -> flow
                .aggregate(a -> a.expireGroupsUponCompletion(true)
                               .outputProcessor(g -> g.getMessages()
                                            .stream()
                                            .filter(m -> m.getPayload() != null)
                                            .map(message-> message.getPayload().toString())
                                            .collect(Collectors.joining(","))));
                }