Adding Jackson databind module for simplified deserialization.#34
Open
aweigold wants to merge 1 commit intoua-parser:masterfrom
Open
Adding Jackson databind module for simplified deserialization.#34aweigold wants to merge 1 commit intoua-parser:masterfrom
aweigold wants to merge 1 commit intoua-parser:masterfrom
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.
bpossolo
requested changes
Aug 14, 2020
| new Device("Other")); | ||
|
|
||
| String expectedSerialization = IOUtils.resourceToString( | ||
| "ua_parser/testClient.json", Charset.defaultCharset(), getClass().getClassLoader()); |
Contributor
There was a problem hiding this comment.
you can read the full file into a string using java nio Files. Don’t need the dependency on commons io
| "device": { | ||
| "family": "Other" | ||
| } | ||
| } No newline at end of file |
Contributor
There was a problem hiding this comment.
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); |
Contributor
There was a problem hiding this comment.
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?
Contributor
|
nice solution to using Jackson without muddying your the models w Jackson annotations |
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. 😄 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.