spring message将json字符串转换为map(spring messaging converting json string to map)

系统教程 行业动态 更新时间:2024-06-14 16:57:40
spring message将json字符串转换为map(spring messaging converting json string to map)

使用Spring Integration,我有一个json字符串(见下文)和以下代码:

public SomethingBean convert(Message<?> inMessage) {...}

Json字符串

{ "addressIdentification": { "identifierType": "nemtom", "addressIdentifier": "eztse" }, "postcode": "BH1EH", "country": "5" }

我想使用以下方法签名:

public SomethingBean convert(Message<Map<String, ?>> inMessage) {...}

是否可以自动将json字符串转换为Map?

谢谢,V。

Using Spring Integration and I have a json string (see below) and the following code:

public SomethingBean convert(Message<?> inMessage) {...}

Json string

{ "addressIdentification": { "identifierType": "nemtom", "addressIdentifier": "eztse" }, "postcode": "BH1EH", "country": "5" }

I'd like to use the following method signature:

public SomethingBean convert(Message<Map<String, ?>> inMessage) {...}

Is it possible to convert the json string to Map automatically?

Thanks, V.

最满意答案

只需使用Spring Integration开箱即用的组件:

<json-to-object-trnsfrormer type="java.util.Map"/>

在SomethingBean调用之前。

Just use Spring Integration out of the box component:

<json-to-object-trnsfrormer type="java.util.Map"/>

before your SomethingBean invocation.

更多推荐

本文发布于:2023-04-13 12:39:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/dzcp/c9d0639f2a4693321e47174322dd381a.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字符串   转换为   message   json   spring

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!