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

[Update] Replace GSON with KotlinX Serialization #2

Merged
merged 5 commits into from
Dec 13, 2023

Conversation

nisrulz
Copy link
Owner

@nisrulz nisrulz commented Dec 13, 2023

Replace serialization using GSON with KotlinX Serialization library.


KotlinX Serialization is better than GSON in many ways:

  1. Type Safety: KotlinX Serialization provides type safety by ensuring that data is serialized with correct types, reducing runtime errors.

  2. Auto-Properties: KotlinX Serialization auto-generates getters and setters, saving time and code.

  3. Advanced Data Structures: KotlinX Serialization supports advanced data structures like classes, interfaces, data classes, and sealed classes for more efficient serialization.

  4. Optional Types: KotlinX Serialization allows nullable values to be specified as ?, making code more robust and flexible.

  5. Built-in Coroutines: KotlinX Serialization provides built-in support for coroutines, improving performance when dealing with large amounts of data or high-traffic APIs.

  6. Method Count: KotlinX Serialization has approximately 100 methods, compared to GSON's approximately 300 methods.

  7. Binary Size: KotlinX Serialization typically has a smaller binary size compared to GSON due to its more efficient data representation and serialization strategies. The exact binary size difference depends on the specific use case and data structures involved, but in general, KotlinX Serialization is around 20-50% smaller than GSON's binary footprint.

  8. Multiplatform: KotlinX Serialization supports multiple platforms, including Android, iOS, Web, and desktop applications, making it a great choice for multiplatform projects.

@nisrulz nisrulz merged commit dd790f8 into main Dec 13, 2023
@nisrulz nisrulz deleted the update/replace-gson-with-kotlinx-serialization branch December 13, 2023 16:57
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.

1 participant