Repository navigation
Doesn't work with @JsonCreator #50
Copy link
Copy link
Open
Description
Trying to deserialize this class fails
@Resource
public class JavaLabel {
@Link
public HALLink self;
public String name;
@JsonCreator
public JavaLabel(
@JsonProperty("self") HALLink self,
@JsonProperty("name") String name)
{
this.self = self;
this.name = name;
}
}
com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Invalid definition for property 'f6de7aa6-e521-4da7-8104-9495ebf67f6b:self' (of type `com.zoovu.permissions.db.JavaLabel`): Could not find creator property with name 'f6de7aa6-e521-4da7-8104-9495ebf67f6b:self' (known Creator properties: [self, name])
at [Source: REDACTED (`StreamReadFeature.INCLUDE_SOURCE_IN_LOCATION` disabled); line: 1, column: 2]
at com.fasterxml.jackson.databind.exc.InvalidDefinitionException.from(InvalidDefinitionException.java:62)
at com.fasterxml.jackson.databind.DeserializationContext.reportBadPropertyDefinition(DeserializationContext.java:1883)
at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.addBeanProps(BeanDeserializerFactory.java:636)
at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.buildBeanDeserializer(BeanDeserializerFactory.java:277)
at com.fasterxml.jackson.databind.deser.BeanDeserializerFactory.createBeanDeserializer(BeanDeserializerFactory.java:151)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer2(DeserializerCache.java:471)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createDeserializer(DeserializerCache.java:415)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCache2(DeserializerCache.java:317)
at com.fasterxml.jackson.databind.deser.DeserializerCache._createAndCacheValueDeserializer(DeserializerCache.java:284)
at com.fasterxml.jackson.databind.deser.DeserializerCache.findValueDeserializer(DeserializerCache.java:174)
at com.fasterxml.jackson.databind.DeserializationContext.findRootValueDeserializer(DeserializationContext.java:669)
at com.fasterxml.jackson.databind.ObjectMapper._findRootDeserializer(ObjectMapper.java:5048)
at com.fasterxml.jackson.databind.ObjectMapper._readValue(ObjectMapper.java:4893)
at com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3036)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels
Activity
arucard21 commentedon Jan 20, 2025
I don't think this repo is really maintained anymore, and I don't use this library myself either. But from the stacktrace, it looks like it has a property
f6de7aa6-e521-4da7-8104-9495ebf67f6b:selfwhich it can't deserialize. Assuming you don't have that exact property name in your original JSON document, the UUID prefix looks like it might be a CURIE prefix. The example Java object you provided doesn't seem to have CURIEs defined so I'm not sure how that would be added. Do you use CURIEs which you didn't include in this example?It seems unlikely that it will help but you could try to explicitly set the name of the
selfvariable in the@Linkannotation as well.But this library might indeed not work with
@JsonCreator. The way the deserialization seems to work (inHALBeanDeserializer.java) is that it modifies the fields in_linksand_embeddedin the deserializer. Then it just passes it back to the original deserializer. So maybe the way it's modified doesn't work with@JsonCreator. But given the lack of maintenance on this library, it seems unlikely that that will be fixed.jakub-bochenski commentedon Jan 20, 2025
Yeah, the
f6de7aa6-e521-4da7-8104-9495ebf67f6b:selfcomes from the library renaming the properties by prefixing them with an UUID, to apply special processing.Part of this processing doesn't activate for @jsoncreator.