-
Notifications
You must be signed in to change notification settings - Fork 16
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
Deserialize JSON using KotlinX Serialization instead of Gson #270
Deserialize JSON using KotlinX Serialization instead of Gson #270
Conversation
Hello @PattaFeuFeu Regarding code style: Detekt for Kotlin code and PMD plus checkstyle for Java code should run once you run Regarding your other questions, I will need to have a look into the code a bit more. Hopefully I can do this tomorrow. |
I am in complete agreement with @PattaFeuFeu. Kotlinx is much better and fits very good for the purposes of this library. By the way, terrific PR |
2413724
to
50d4bee
Compare
50d4bee
to
02dea17
Compare
This is totally fine, even better! Quickly checked Mastodon API docs and that's actually how the data is returned from the server. So all good! 👍 |
Definitively. Go ahead! Looking forward to your changes! |
I have gone through your code changes and must say, that this is looking very good so far. Looking forward to some test runs, once it is ready 🙂Thanks for the effort you put into this! Highly appreciated! |
02dea17
to
2fe0cdd
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## master #270 +/- ##
=============================================
- Coverage 47.07% 35.87% -11.21%
+ Complexity 357 348 -9
=============================================
Files 100 101 +1
Lines 3006 3033 +27
Branches 164 183 +19
=============================================
- Hits 1415 1088 -327
- Misses 1522 1825 +303
- Partials 69 120 +51
|
82deeb4
to
e040d67
Compare
@andregasser I think I’m mostly done. I will update the description soon and will add the pull request template to the bottom of the PR description with additional info. How do we want to handle the decrease in code coverage? As all tests are still passing and I didn’t really add new functionality and rather replaced a dependency, I would personally ignore it (which also is the reason why I’m a bit sceptical of code coverage tools as “false positives” like this can happen easily). If you’d like, I could potentially add some additional tests for edge cases. I introduced nullability in a few places where previously potential nullability was just ignored or covered up in a generic exception. |
Do not worry about the test coverage tool output too much, as I am also not 100% happy with it yet. Because of this, I also did not set I will do some test runs based on the changes in this PR very soon. Thanks for the update 🙂 |
# Conflicts: # bigbone/src/main/kotlin/social/bigbone/api/entity/Report.kt
# Conflicts: # bigbone/src/main/kotlin/social/bigbone/api/entity/Relationship.kt
sample-kotlin/src/main/kotlin/social/bigbone/sample/GetInstanceInfo.kt
Outdated
Show resolved
Hide resolved
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.
Overall, it looks very good, I have just added two minor comments. Thx!
# Conflicts: # bigbone/build.gradle # gradle/libs.versions.toml
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.
This looks good to me! Regarding some of the mostly code style questions brought up earlier:
- changing id-related properties in test data to string: this is correct. We've had to change all id types to strings earlier this year, the test data is probably mostly left over from before that change.
- using argument names: I don't think it has ever been a conscious choice not to use them. I prefer them for clarity as well, so as far as I am concerned, we should keep it this way and use argument names throughout.
Fine for me as well. Let's use argument names in a consistent way. Thanks for your review, @bocops ! |
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.
Ok!
accidentally removed in andregasser#270
Description
In this PR, I replace GSON as the JSON (de-)serialiser of choice with KotlinX’ Serialization library.
#224 mentioned Jackson as one of the options but KotlinX Serialization seems like a better fit to me with it being a KotlinX library and thus hopefully even better support and more “kotlin-y” APIs.
The Java usage sometimes gets a bit clunky but that shouldn’t be an issue as we don’t expose the serializer. I have made it an internal dependency, as opposed to GSON which was an
api
instead ofimplementation
gradle dependency.The usage of GSON in this project was pretty basic but if we need more advanced customer deserializers, this Medium article about this exact migration could come in handy.
Type of Change
How Has This Been Tested?
I ran
gradle check
and tested the Kotlin and Java sample app with a test instanceChecklist
History of this description as some comments already referenced the old state:
This PR should in the end close #224.
State of this PR
This PR is not yet entirely ready for review. It’s just a first work in progress that I’d like your feedback on. @andregasser
Code style
When I applied code style settings from this project in IntelliJ IDEA, auto-formatting changed loads of lines so I assume there’s no style added to the project? I went for the Kotlin defaults then which seemed to mostly not change too much. I did not merge auto-formatting changes unrelated to this PR’s main changes though.
Usually, I use argument names heavily but this project doesn’t seem to do that. Was that a conscious choice? If so, I’m glad to remove the few additions again. If not, I’ll keep them. 😊
Same for
var
/val
types andfun
return types. I usually explicitly add them as well but also couldn’t see that everywhere here.Still open
I needed to litter the JSON config in a few different files and for finishing up I’d like to find a better approach here that would still ensure that we’re using the same config everywhere without adding too much coupling. I already don’t like the JSON serializer being part ofMastododonClient
but I wanted to keep this PR as close to the original GSON usage as possible for now.