Created
October 13, 2021 01:15
-
-
Save navczydev/b5156c204c82d5a8f2a0ec8be15025a1 to your computer and use it in GitHub Desktop.
This file contains 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
val formatExplicitExcludeNullsFalse = Json { explicitNulls = false } | |
val flutterExpert = Expert(id = 1, "Roman", Category.FLUTTER, null) | |
val jsonFlutterExpert = formatExplicitExcludeNullsFalse.encodeToString(flutterExpert) | |
println("Encoded FlutterExpert result: $jsonFlutterExpert") | |
val formatExplicitExcludeNullsTrue = Json { explicitNulls = true } | |
println("Decoded FlutterExpert: ${formatExplicitExcludeNullsTrue.decodeFromString<Expert>(jsonFlutterExpert)}") | |
/* | |
Exception in thread "main" kotlinx.serialization.MissingFieldException: | |
Field 'publishedArticles' is required for type with serial name 'Expert', but it was missing | |
at kotlinx.serialization.internal.PluginExceptionsKt.throwMissingFieldException(PluginExceptions.kt:20) | |
*/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment