Repository navigation
feat: migrate from GSON to kotlinx.serialization - #1340
Open
ibrahim-iqbal wants to merge 1 commit into
Open
ibrahim-iqbal wants to merge 1 commit into
ibrahim-iqbal wants to merge 1 commit into
Conversation
Replace Gson with kotlinx.serialization across the entire codebase: - Swap retrofit-gson for retrofit-kotlinx-serialization in version catalog - Replace GsonConverterFactory with Json.asConverterFactory in NetworkDataSource - Add @serializable and @SerialName annotations to all DTO classes (LatestRelease, AssetsItem, GoogleReaderDTO.*, Diff) - Migrate SecurityKey hierarchy to use reified inline decode<T>() with @PublishedApi internal Json instance (addresses PR ReadYouApp#997 review feedback about keeping abstract class, not sealed) - Replace Gson in ProviderAPI, DiffMapHolder, and DataStoreExt with kotlinx.serialization equivalents using MapSerializer and JsonElement - Add SerializationCompatibilityTest verifying JSON round-trip compatibility with previous Gson output format Closes ReadYouApp#994
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.
Summary
Migrates the entire codebase from GSON to kotlinx.serialization, addressing #994.
Changes
converter-gsonforconverter-kotlinx-serialization(Retrofit 2.11.0 built-in support) withJson { ignoreUnknownKeys = true }@Serializableand@SerialNameannotations to all data classes (LatestRelease,AssetsItem, allGoogleReaderDTO.*classes,Diff)decode()to use reified type parameters with@PublishedApi internalJson instance — keeps the abstract class approach (per maintainer feedback on feat: replace gson with kotlinx.serialization #997)GsonwithJsonandMapSerializer/JsonElementfor generic map serializationretrofit-gson→retrofit-kotlinx-serializationCompatibility
@SerialNamewhere Gson used@SerializedNameignoreUnknownKeys = trueensures forward compatibility with API responsesTests
Added
SerializationCompatibilityTestthat:Tests bypass DESUtils (which depends on
android.util.Base64) and test the JSON serialization layer directly.Related
Test plan
./gradlew compileFdroidDebugKotlin✅./gradlew testFdroidDebugUnitTest --tests SerializationCompatibilityTest