Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jackson json provider linkedHashSet deserialization

We are using Spring rest template and jackson json provider to serialize/deserialize json. From my services i send a linkedHashSet back which gets converted to a HashSet on the client side when i receive it. Because of this I loose my insertion order of elements. Is this the default implementation of jackson json provider for Set ? Is there any other way, so it can deserialize to proper implementation? I feel it's gonna be tricky but inputs will be highly appreciated from you guys.

Thanks

like image 856
Ashish Thukral Avatar asked Aug 14 '13 19:08

Ashish Thukral


1 Answers

You can specify the concrete class for Jackson to use with the @JsonDeserialize annotation. Just put:

@JsonDeserialize(as=LinkedHashSet.class)

On the property's setter.

like image 169
Affe Avatar answered Oct 04 '22 02:10

Affe