Skip to content

Serializing Map.Entry as Bean with @JsonFormat.shape = Shape.OBJECT fails on JDK 17+ #4963

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

Closed
cowtowncoder opened this issue Feb 9, 2025 · 0 comments

Comments

@cowtowncoder
Copy link
Member

So, with configuration like:

 ObjectMapper mapper = JsonMapper.builder()
                .withConfigOverride(Map.Entry.class, cfg ->
                    cfg.setFormat(JsonFormat.Value.forShape(JsonFormat.Shape.OBJECT)))
                .build();

attempts to serialize Map.Entry of JDK Maps (like LinkedHashMap) fails due to access problems (unless --add-opens is used).

There is an existing test that fails this way. But we should be able to have a serializer that works with public API in this case.

cowtowncoder added a commit that referenced this issue Feb 9, 2025
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

1 participant