Last active
March 13, 2023 08:21
-
-
Save trinnguyen/9905c5031400cd89f990f18bdd0c61e2 to your computer and use it in GitHub Desktop.
Kotlin serialization json object
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
import kotlinx.serialization.ExperimentalSerializationApi | |
import kotlinx.serialization.encodeToString | |
import kotlinx.serialization.json.Json | |
import kotlinx.serialization.json.JsonElement | |
import kotlinx.serialization.json.decodeFromJsonElement | |
import kotlinx.serialization.json.decodeFromStream | |
import java.io.InputStream | |
/** | |
* A default json object that relaxes with API changes | |
* https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/json.md | |
*/ | |
val jsonObj = Json { | |
this.isLenient = true | |
this.ignoreUnknownKeys = true | |
this.encodeDefaults = true | |
this.explicitNulls = false | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment