java - Jackson deserialize JsonIdentityReference (alwaysAsId = true) -


following on question: question here

@jsonidentityreference(alwaysasid = true) , @jsonidentityinfo(generator = objectidgenerators.propertygenerator.class) works great serialization end, not when comes time deserialize since can't resolve object id reference.

is there way deserialize? writing custom deserializer seems overkill.

instead of custom deserializer, can use simple setter deserializer:

public class container {     @jsonidentityinfo(generator = objectidgenerators.propertygenerator.class, property = "id")     @jsonidentityreference(alwaysasid = true)     private foo foo;      public foo getfoo() {         return foo;     }     public container setfoo(foo foo) {         this.foo = foo;         return this;     }     @jsonproperty("foo")     public void setfoo(string id) {         foo = new foo().setid(id);     } } 

example string of {"foo":"id1"} serialized method in jackson 2.5.2


Popular posts from this blog

php - How should I create my API for mobile applications (Needs Authentication) -

python 3.x - PyQt5 - Signal : pyqtSignal no method connect -

5 Reasons to Blog Anonymously (and 5 Reasons Not To)