Skip to content

Commit de140ed

Browse files
GooolerMarcono1234
andauthored
Document using Kotlin Serialization or Moshi instead (#2857)
* Document using Kotlin Serialization or Moshi instead * Update README.md Co-authored-by: Marcono1234 <[email protected]> * Update README.md Co-authored-by: Marcono1234 <[email protected]> * Update the info about Moshi * Update README.md --------- Co-authored-by: Marcono1234 <[email protected]>
1 parent f75118e commit de140ed

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

README.md

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,11 @@ There are a few open-source projects that can convert Java objects to JSON. Howe
1313
> When using languages other than Java, prefer a JSON library with explicit support for that language.
1414
1515
> [!IMPORTANT]\
16-
> Gson is not a recommended library for interacting with JSON on Android. The open ended reflection in the Gson runtime doesn't play nicely with shrinking/optimization/obfuscation passes that Android release apps should perform.\
17-
> If your app or library may be running on Android, instead look at [Kotlin Serialization](https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/basic-serialization.md#basics) which uses code generation instead of reflection. This avoids Gson's runtime crashes when optimizations are applied, and results in faster performance on Android devices. If you still want to use Gson and attempt to avoid these crashes, you can see how to do so [here](Troubleshooting.md#-proguard--r8).
16+
> Gson is not a recommended library for interacting with JSON on Android. The open-ended reflection in the Gson runtime doesn't play nicely with shrinking/optimization/obfuscation passes that Android release apps should perform.\
17+
> If your app or library may be running on Android, consider using [Kotlin Serialization](https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/basic-serialization.md#basics) or [Moshi's Codegen](https://github.com/square/moshi?tab=readme-ov-file#codegen),
18+
> which use code generation instead of reflection. This avoids Gson's runtime crashes when optimizations are applied (usually due to the fields missing or being obfuscated), and results in faster performance on Android devices.
19+
> The Moshi APIs may be more familiar to users who already know Gson.
20+
> If you still want to use Gson and attempt to avoid these crashes, you can see how to do so [here](Troubleshooting.md#proguard-r8).
1821
1922
### Goals
2023
* Provide simple `toJson()` and `fromJson()` methods to convert Java objects to JSON and vice-versa

0 commit comments

Comments
 (0)