Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Add common DockerObject parent to every model class #1635

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

Merged
merged 11 commits into from
Jun 17, 2021
Merged

Conversation

bsideup
Copy link
Member

@bsideup bsideup commented May 27, 2021

No description provided.

@bsideup bsideup added this to the next milestone May 27, 2021
public Object deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
JsonNode jsonNode = p.readValueAsTree();

Object deserializedObject = originalMapper.treeToValue(jsonNode, beanDescription.getBeanClass());

Choose a reason for hiding this comment

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

Jackson 2.13 will help here with method DeserializationContext.readTreeAsValue(JsonNode, Class), but alas not yet available. But there is DeserializationContext.readTree(JsonParser) which has some small benefits over going through JsonParser -- probably not much difference here just minor improvement.

Copy link
Member Author

Choose a reason for hiding this comment

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

@cowtowncoder thanks for having a look!
I tried DeserializationContext.readTree(JsonParser) but ended up getting a recursive problem 😅 Hence the "originalMapper" workaround.

Choose a reason for hiding this comment

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

Ah. Odd... would be interested in details if you have any (just to see if there's something to fix), but makes sense to skip in that case.

Copy link
Member Author

Choose a reason for hiding this comment

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

As now I have your aura around, let me try it again and report back :)
Can also share how to try it, without even having Docker running (a.k.a. in memory)

Choose a reason for hiding this comment

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

Sounds good!

Copy link
Member Author

Choose a reason for hiding this comment

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

Ah, okay, I am stupid :D I confused readTree with readValue 😅

readValue gives a recursive problem, while JsonNode jsonNode = ctxt.readTree(p); (previous line) works just fine, thanks!

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

Successfully merging this pull request may close these issues.

2 participants