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) -

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

Google AdWords and AdSense - A Dynamic Small Business Marketing Duo