Replace Gson and org.json with kotlinx.serialization
See original GitHub issueWhy/Project’s Benefit/Existing Problem
There are in the repo actually:
1 file that uses Gson;4 files that uses JsonParser from Gson;14 files that uses Kotson; and- 7 files that uses org.json
All the usages of other Json libraries for deserialization should be replaced by kotlinx.serialization.
Other details
The Json
singleton instance with ignoreUnknownKeys = true
from the main app can be reused:
private val json: Json by injectLazy()
It is not needed to add the kotlinx.serialization dependency to the extensions that uses it (with Json or ProtoBuf), since it was already added to common-dependencies.gradle
. However, extensions that make usage of the library must add this one line after the kotlin-android
plugin at the extension’s Gradle file:
apply plugin: 'kotlinx-serialization'
Additional documentation
Issue Analytics
- State:
- Created 2 years ago
- Reactions:2
- Comments:13 (10 by maintainers)
Top Results From Across the Web
Kotlinx Json vs Gson. Let's look at how new Kotlin… - Medium
This means that gson deserialization even breaks kotlin null-safety and may cause app crash. To prevent this unwanted behavior, you could use ...
Read more >Use Kotlinx Serialization Library to Parse JSON Data From ...
We generally use the famous GSON, Moshi library to parse JSON data coming from api/network calls using Retrofit. But now it becomes the...
Read more >What is equals of Gson.fromJson() in Kotlinx.serialization?
What is equals of Gson.fromJson() in Kotlinx.serialization? ... I want to move from Gson to kotlinx.serialization , what is equals of this to ......
Read more >kotlinx.serialization 1.2 Released: High-Speed JSON ...
JSON serialization is faster than ever before. Version 1.2 is up to twice as fast as previous versions when parsing JSON into type-safe...
Read more >kotlinx.serialization 1.2.0: Faster JSON Handling ... - YouTube
Join us for the Kotlin 1.5 Online Event! https://kotl.in/youtube-eventThe event will feature a live Q&A session with the Kotlin team.
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Which we do now go away
Closing this since replacing
org.json
isn’t really necessary, although it is a nice-to-have.