-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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
Class with @JsonTypeInfo cannot be @JsonUnwrapped #81
Comments
Yes, this would be tricky to support properly, and requires both serialization and deserialization to work around the complications. There is a chance that this combination can not be supported; but if so, it could either throw a more descriptive exception, or just ignore unwrapping handling. Both approaches have their downsides. Not sure what Afterburner does, although I would guess that it might just disable unwrapping handling altogether? |
Yeah, I was incorrect before; afterburner is simply ignoring the @JsonUnwrapped annotation. I would have assumed that an error would be the most appropriate response, personally. |
Afterburner code is bit fragile since it relies on inheritance, and as unwrapped struct handling is newer than AB, it has not been updated to try to figure out unwrapping aspects if any. But it would probably make sense for AB to avoid optimizing Bean(De)Serializers that do unwrapping and leave it to default handling. |
…upport FasterXML/jackson-dataformat-xml/FasterXML#81.
What is the recommended workaround? |
I have managed to patch this locally by simply skipping the writing of type id information for properties being unwrapped. Hopefully this is a valid solution? It prevents the error from happening but obviously we still lose the type information. I think that's an ok start, as it at least enables the classes to be used in a top level and unwrapped scenario without error. |
I added notes on #455; basically I am bit worried about default behavior of skipping writing of type info. But I agree in that failing when trying to write is also not much of a solution... so perhaps a |
@cowtowncoder Would the feature basically give Jackson permission to omit type information for these cases? |
@UnquietCode Right, it would do that. So just guard this feature to be used only when explicitly enabled -- I am still worried about side effects, or this hiding some other problems. It is easier to explain alternative processing when it is explicitly enabled. |
Sounds good to me. I added some stubs to #455 for such a feature. Probably some cleanup or renaming is required. I wasn't able to get the full JSON path information into the exception message. |
Merged #455, so this is sort of supported now. |
Test and bug fix for Issue FasterXML#81: CharTypers.appendQuoted misencodes first 32 Unicode values as '\0000'.
... in version 2.0.6. It yields an internal error "Can not start object, expecting field name".
Appears to me it's because UnwrappingBeanSerializer is not overriding serializeWithType(). The fix doesn't look simple, though, as the TypeSerializer interface seems to assume an embedded object.
The text was updated successfully, but these errors were encountered: