-
Notifications
You must be signed in to change notification settings - Fork 11
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Object ID Deserialization #1
Comments
Hi, Take a look on this http://wiki.fasterxml.com/JacksonFeatureObjectIdentity I'm declaring that annotation in the POJO's classes @JsonIdentityInfo(generator = ObjectIdGenerators.PropertyGenerator.class, property = "id")
public class AnotherResource {
...
} The annotation is used when deserializing to create a new object that will have the id property filled with the value posted with the json snippet. The public class Resource {
@JsonIdentityReference(alwaysAsId = true)
@JsonProperty("another_resource_id")
private AnotherResource anotherResource;
...
} |
Yes, I understand that this works with serialization, i.e the json the server outputs is correct. |
You need add a method in Resource class to create a AnotherResource object from the id too. @JsonSetter
public void setAnotherResource(Long id) {
System.out.println("Creating AnotherResource " + id);
this.anotherResource = new AnotherResource(id);
} |
Good idea! Thank you for your help! |
Hi!
This is a great resource for those interested in using Ember and Java Web Services. Thanks!
I see you're using some clever "tricks" with jackson. It's awesome.
But one thing I couldn't manage to get is the Deserialization of relationships.
Serializations works fine.
For example. A
GET
to/resources
returns:The
AnotherResource
id gets serialized.But when you
POST
a resource, with this payload, for example:Do you have a successful save? I'm getting an error in Jackson. I can't deserialize using only the id. There's already a related issue with this, and I reported my problem here: FasterXML/jackson-databind#176 (comment)
How are you doing this?
The text was updated successfully, but these errors were encountered: