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 failing test for #4047 #4049

Conversation

JooHyukKim
Copy link
Member

@JooHyukKim JooHyukKim commented Jul 20, 2023

Reproduces #4047

@JooHyukKim JooHyukKim changed the title Add failing test for #4047 (ObjectMapper.valueToTree ignores SerializationFeature.WRAP_ROOT_VALUE) Add failing test for #4047 Jul 20, 2023
@JooHyukKim JooHyukKim changed the title Add failing test for #4047 [DRAFT] Add failing test for #4047 Jul 20, 2023
}


public void testTreeToValue() throws Exception
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/cc

*/
UNWRAP_MAPPER.readTree(WRAPPED_EVENT_JSON);
UNWRAP_MAPPER.readTree(UNWRAPPED_EVENT_JSON);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

/cc

Copy link
Member Author

@JooHyukKim JooHyukKim Jul 22, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When DeserializationFeature.UNWRAP_ROOT_VALUE is enabled, readTree() works like

    UNWRAP_MAPPER.readValue(WRAPPED_EVENT_JSON, JsonNode.class);

But, should it?

Copy link
Member

@cowtowncoder cowtowncoder Jul 25, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is tricky: my thinking all along has been that no, WRAP/UNWRAP related to POJOs and should not affect JsonNode: JsonNode (tree model in general) being used to represent JSON exactly as is, with no (or minimal) translations: no naming conventions, no ignorals... and hence no wrapping/unwrapping.

But then again some users disagree, and maybe more importantly, implementation may be such that wrapping/unwrapping occurs outside control of (de)serializer being used.

I suspect this could actually be one reason for handling of:

mapper.readTree(source);
mapper.readValue(source, JsonNode.class);

to possibly differ.

@JooHyukKim JooHyukKim changed the title [DRAFT] Add failing test for #4047 Add failing test for #4047 Jul 25, 2023
…alueToTree-will-ignore-the-configuration-SerializationFeature.WRAP_ROOT_VALUE-
@cowtowncoder
Copy link
Member

Could this be merged with PR #4050 ?

@JooHyukKim
Copy link
Member Author

@cowtowncoder sure. Will do. Plain merge or exclude some?

@cowtowncoder
Copy link
Member

@cowtowncoder sure. Will do. Plain merge or exclude some?

Maybe copy ones relevant to initial case, valueToTree().

Maybe follow-up issue/PR for treeToValue(), if and as relevant.

@JooHyukKim
Copy link
Member Author

JooHyukKim commented Jul 26, 2023

EDITED
@cowtowncoder If so, the same test case is already there in #4050. I think we can simply close this and open another issue for readTree (which I think you meant by treeToValue) as discussed wrt #4049 (comment)

@JooHyukKim
Copy link
Member Author

Closing

as per notes above #4049 (comment)

@JooHyukKim JooHyukKim closed this Jul 26, 2023
@JooHyukKim JooHyukKim deleted the 4047-ObjectMapper.valueToTree-will-ignore-the-configuration-SerializationFeature.WRAP_ROOT_VALUE- branch July 28, 2023 13:43
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

Successfully merging this pull request may close these issues.

2 participants