Skip to content
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

Add feature WRAP_IDENTIFIER_IN_OBJECT to allow disabling of wrapping of "id" attribute #136

Open
jobosk opened this issue Jul 1, 2020 · 3 comments
Milestone

Comments

@jobosk
Copy link
Contributor

jobosk commented Jul 1, 2020

I've noticed that Feature SERIALIZE_IDENTIFIER_FOR_LAZY_NOT_LOADED_OBJECTS works as inteded (serializing attributes from the Hibernate proxy of lazy loaded objects, i.e. identifiers), but wrapped like this:

{ "id" : 1 }

This means the (lazy) relation to Foo in the following object would be serialized as:

{ ... , foo: { "id" : 1 }, ... }

I have found standard behaviour to be the following:

{ ... , foo: 1, ... }

For example, when using "@JsonIdentityInfo" annotation, Jackson would resolve relations as numeric IDs to break circular dependencies (i.e. the entity has already been visited and fully serialized).

I would like to know if this is a known issue or is it just me that finds odd the default behaviour.
But anyway, I'd be happy to implement a new backwards-compatible feature to achieve it.

@cowtowncoder
Copy link
Member

cowtowncoder commented Jul 8, 2020

I don't really know the answer as this module in general, and feature in particular, came as contribution.
So the feature for making wrapping optional sounds reasonable.

@cowtowncoder
Copy link
Member

As per notes on PR #137 will be merging as soon as we get CLA.

@cowtowncoder cowtowncoder changed the title Feature SERIALIZE_IDENTIFIER_FOR_LAZY_NOT_LOADED_OBJECTS wraps "id" attribute Add feature WRAP_IDENTIFIER_IN_OBJECT to allow disabling of wrapping of "id" attribute Jul 11, 2020
@cowtowncoder cowtowncoder added this to the 2.12.0 milestone Jul 11, 2020
cowtowncoder added a commit that referenced this issue Jul 11, 2020
@cowtowncoder
Copy link
Member

Merged, will be in 2.12.0. Thank you @jobosk for contributing this!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants