Skip to content

Add common DockerObject parent to every model class#1635

Merged
bsideup merged 11 commits intomasterfrom
add_DockerObject
Jun 17, 2021
Merged

Add common DockerObject parent to every model class#1635
bsideup merged 11 commits intomasterfrom
add_DockerObject

Conversation

@bsideup
Copy link
Copy Markdown
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());
Copy link
Copy Markdown

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
Copy Markdown
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.

Copy link
Copy Markdown

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
Copy Markdown
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)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Sounds good!

Copy link
Copy Markdown
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