Eran Medan
Eran Medan

Reputation: 45765

Deserialization of Sets / Lists from JSON using Jackson and Spring 3.0 fails

I'm having a trouble desirializing POJO objects that contains sets

e.g.

class C {
    Set<SomeObject> set;
    ...
}

Using Jackson 1.8 auto mapping, I get all properties correctly, but if I use a set I get this

org.codehaus.jackson.map.JsonMappingException: Unexpected token (START_OBJECT), expected VALUE_STRING: need JSON String that contains type id (for subtype of java.util.Set)

Any Ideas what I'm doing wrong? is Generics in type / type erasure is the culprit? how do I fix it then?

Disclaimer, I'm using Hibernate persistent entities when I'm serializing and deserializing is out of session

Upvotes: 0

Views: 1729

Answers (1)

StaxMan
StaxMan

Reputation: 116582

Structure of JSON data differs from structure of POJO; if you can include JSON here it should be easy to figure out where exactly mismatch occurs. Sets should be handled just fine, but they need to match with JSON arrays.

Upvotes: 3

Related Questions