Deserialize List of Maps in RestTemplate



I've tried to find a solution here but with no success.

I have external service that serializes some data and returns xml in form:



<linked-list>
<linked-hash-map>
<entry>
<string>key1</string>
<string>value</string>
</entry>
<entry>
<string>key2</string>
<string>value2</string>
</entry>
</linked-hash-map>
<linked-hash-map>
....
</linked-hash-map>
</linked-list>


Basically it returns List of Maps List<Map<String, String>>


In my application I need to deserialize it using Spring's RestTemplate.

Relying on default message converters all I get is list of maps, but each map contains only one element with key "entry" and the value seems to be the last element in original (xml) map.


Is there a way for this to work "out of the box" using some existing coverter, or do I need a custom one? And also using custom, how to bypass deserializing by ex. MappingJackson2XmlHttpMessageConverter or MappingJackson2HttpMessageConverter ?


No comments:

Post a Comment