-
Notifications
You must be signed in to change notification settings - Fork 177
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
base: master
Are you sure you want to change the base?
Conversation
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()); |
There was a problem hiding this comment.
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" | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
needs a newline.
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
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?
nice solution to using Jackson without muddying your the models w Jackson annotations |
@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. 😄 |
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.