Open awildturtok opened 3 years ago
Hmmhm.
Unfortunately this may actually work as expected: existence of @JsonCreator
does not mean that no properties would be used: it is expected that only some of properties would be passed through constructor.
But this would only apply for "as-properties" case, however; in this case I think mode is expected to be delegation style, as if creator annotation was:
@JsonCreator(mode = JsonCreator.Mode.DELEGATING)
and if so, no real properties will be used. Code probably is not structured in a way to be able to avoid property introspection, however.
One thing to try is to use an up-to-date version of databind -- 2.12.4 is the latest. But I don't expect that to make a difference here.
So, this seems like something that would be good to improve on but not necessarily easy to do.
Thanks for your answer. I suspected as much, after reading other issues related to JsonCreator.
So, this seems like something that would be good to improve on but not necessarily easy to do.
I agree it's not extremely important, but would lazy/ad-hoc loading property deserializers not be sufficient here? It seems to me, that at the moment Jackson tries to cover all bases before deserializing, but if the Creator already consumed all properties we shouldn't try to introspect the others?
@awildturtok Right, the challenge tho is that public
property with name map
would infer existence of property map
which is not covered by another property. Logically of course "delegating" approach will prevent need and use of any properties, so this SHOULD be detected by Jackson. So it is more of a limitation.
It is also true that in some cases processing may be deferred, but this is bit of double-edged sword -- many users prefer early failure on detected issues; whereas in some cases the opposite is desired (theoretical problem never encountered).
I think there is a valid improvement to do here so I changed the title slightly, marked for consideration in 2.14, and I hope this can be tackled in future.
In the meantime, use of @JsonIgnore
is the recommended work-around if anyone else needs it.
Describe the bug
I am trying to Serialize a class that has weird map-Types (eg. String[] as key), instead of implementing a Map(De)Serializer, I went the way of a @JsonValue and @JsonCreator, using an intermediate Container class as intermediary. This does work, however Jackson is giving me Errors about not finding appropriate Key-Deserializers (Which of course is true, but shouldn't happen as I am explicitly forgoing them). When I mark the Map field with @JsonIgnore, the Objects are properly (de)serialized.
Version information
2.10.5
To Reproduce
Expected behavior
I would expect that a class annotated with @JsonCreator will not try to find deserializers for it's fields, or at least only for those properties not covered by the @JsonCreator (ie after the fact).