question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Replace Gson and org.json with kotlinx.serialization

See original GitHub issue

Why/Project’s Benefit/Existing Problem

There are in the repo actually:

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:closed
  • Created 2 years ago
  • Reactions:2
  • Comments:13 (10 by maintainers)

github_iconTop GitHub Comments

4reactions
CarlosEscocommented, Jun 4, 2021

Which we do now go away

0reactions
arkoncommented, Dec 12, 2021

Closing this since replacing org.json isn’t really necessary, although it is a nice-to-have.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found