使用 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?
谢谢, 五、
最佳答案
只需使用开箱即用的 Spring Integration 组件:
<json-to-object-trnsfrormer type="java.util.Map"/>
在您的 SomethingBean
调用之前。
关于java - spring messaging 将 json 字符串转换为映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25748719/