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

Adding Jackson databind module for simplified deserialization. #34

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

aweigold
Copy link

@aweigold aweigold commented Jan 4, 2019

This commit adds compile only dependencies to Jackson databind, to
provide simplified deserialization of ua_parser models for consumers
using the library.

As this is compile only, no impact is expected to consumers not using
Jackson. However by including this boilerplate code, Jackson now can
deserialize directly into ua_parser models in projects that may have
stored them previously.

This commit adds compile only dependencies to Jackson databind, to
provide simplified deserialization of ua_parser models for consumers
using the library.

As this is compile only, no impact is expected to consumers not using
Jackson.  However by including this boilerplate code, Jackson now can
deserialize directly into ua_parser models in projects that may have
stored them previously.
new Device("Other"));

String expectedSerialization = IOUtils.resourceToString(
"ua_parser/testClient.json", Charset.defaultCharset(), getClass().getClassLoader());
Copy link
Contributor

Choose a reason for hiding this comment

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

you can read the full file into a string using java nio Files. Don’t need the dependency on commons io

"device": {
"family": "Other"
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

needs a newline.

Copy link
Contributor

Choose a reason for hiding this comment

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

file name should reflect the unit test it’s associated with:
jackson-module-databinding-test.json

"ua_parser/testClient.json", Charset.defaultCharset(), getClass().getClassLoader());

String actualSerialization = objectMapper.writeValueAsString(testClient);
JSONAssert.assertEquals(expectedSerialization, actualSerialization, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

would you be open to just using string equality for this check rather than pulling in another library just for one line of one unit test?

@bpossolo
Copy link
Contributor

nice solution to using Jackson without muddying your the models w Jackson annotations

@aweigold
Copy link
Author

@bpossolo I submitted this over a year and a half ago... I'm probably not going to get to changes requested. Feel free to modify and take the code as you wish. 😄

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