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