kotlinx.serialization Questions
2
Solved
I have generated some models using the Open API tool on one of our backend APIs with Swagger. I got the following as the enum definition:
@Serializable
enum class ClientBackgroundState(val value: k...
Audraaudras asked 30/5, 2022 at 11:37
6
Solved
I have a problem with the serialization of a class in Kotlin.
build.gradle.kt
...
plugins {
application
kotlin("jvm") version "1.6.21"
kotlin("plugin.serialization"...
Vincent asked 24/4, 2022 at 11:56
2
Solved
I want to decode a json string containing a list of objects in a polymorphic class structure using kotlinx.serialization in a Kotlin Multiplatform project, but it works only on JVM, not on Native. ...
Americium asked 9/3, 2021 at 20:8
2
import kotlinx.serialization.Serializable
@Serializable
sealed class Exercise(open val id: String) {
@Serializable
data class Theory(override val id: String) : Exercise(id)
}
I have such kind ...
Hypomania asked 30/7, 2020 at 12:22
1
How would I go about serializing LocalDateTime using kotlinx serializer
I've read that I would need to include implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.4.0") in my depende...
Shaven asked 28/3, 2023 at 6:8
3
Solved
I'm using kotlinx.serialization in conjunction with retrofit. The json response that I receive will vary in terms of what attributes it will contain. In most cases, the data model in my app has mor...
Calypso asked 11/10, 2019 at 2:9
3
I'm having a hard time finding documentation on how to deserialize date fields.
How do i achieve this? Most solutions i found on SO don't work or they use classes that are no longer available
@Seri...
Ruck asked 28/4, 2021 at 18:21
2
Solved
I am trying to serialize a json, but its throwing JsonDecodingException. Check the code:
SerializationTestCase.kt:
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
...
Efficiency asked 18/3, 2021 at 12:1
2
Solved
I have a JSON string that looks like {"code": "FOO"}.
Now I want to deserialize this string using kotlinx.serialization. I've tried the following:
import kotlinx.serialization.*...
Sidesaddle asked 10/9, 2020 at 8:57
2
Solved
I am writing a Kotlin multiplatform project (JVM/JS) and I am trying to parse a HTTP Json array response into a Map using Kotlinx.serialization
The JSON is something like this:
[{"someKey": "some...
Bake asked 14/4, 2019 at 12:50
4
Solved
I want convert my json string response from API to object:
val obj = Json.decodeFromString<MyModel>(jsonResponseString)
My data class:
@Serializable
data class MyModel(
@SerializedName(&quo...
Levitt asked 24/12, 2020 at 20:38
2
Solved
There is an example of a class with a default value:
@Serializable
data class TestClass(
val obligatory: String,
val optional: Int = 0
)
It can be correctly deserialize from jsons like: { "...
Amorino asked 1/9, 2021 at 6:42
1
Solved
I'm using Kotlin/JVM 1.8.0 and Kotlinx Serialization 1.4.1.
I need to encode a java.math.BigDecimal and java.math.BigInteger to JSON.
I'm using BigDecimal and BigInteger because the values I want t...
Harborage asked 27/1, 2023 at 11:55
1
Solved
I want to create a class that looks roughly like this:
class MyWrapperClass<T: IsSerializable>(val someData: T) {
fun stringifyMe(): String {
return Json.encodeToString(someData)
}
}
M...
Ribaudo asked 19/12, 2022 at 5:43
6
Solved
Let's say I'm having a class like:
@Serializable
data class MyClass(
@SerialName("a") val a: String?,
@SerialName("b") val b: String
)
Assume the a is null and b's value is "b value", then Jso...
Cicada asked 23/9, 2019 at 6:4
1
Solved
I use kotlinx.serialization library to serialize/deserialize JSONs. There is a JSON string:
{"id":"1"}
that can be also represented as
{"uid":"1"}
And I wa...
Sedgemoor asked 10/10, 2022 at 13:49
2
Solved
I'm generating JSON for a number of third-party APIs. Many of them accept a list (JSON array) of different objects, however, none of them will accept the "type": "com.mycom.someclass" automatically...
Meliamelic asked 27/5, 2020 at 22:8
3
Solved
I am trying to figure out how to check the http status code of a http request with Ktor
I have a simple GET request like this with a HttpResponseObject that holds the data the server returns and ...
Clypeate asked 4/5, 2020 at 20:4
1
Solved
I am trying to consume and emit JSON which contains a polymorphic list of items. The problem is: the items contain type key with integer values (not strings). The API endpoint produces and expects ...
Withstand asked 27/7, 2022 at 14:26
10
I'm trying to initialize Ktor http client and setup json serialization. I need to allow non-strict deserialization which JSON.nonstrict object allows. Just can't get how to apply this setting to se...
Hillock asked 29/11, 2018 at 20:55
1
Solved
I am facing issues with serialization using Kotlin. I've followed through the steps here https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/serialization-guide.md but unfortunately, n...
Parachute asked 23/7, 2022 at 13:18
2
Not sure if it is possible yet but for the life of me I cannot figure out how to serialize this.
sealed class ServiceResult<out T : Any> {
data class Success<out T : Any>(val data: T) ...
Lumpish asked 13/11, 2020 at 19:15
1
Solved
My resialized is "{"2":"Hello","Tesst":"Value"}"
I tried to parse this string to Map<String,String>
val resialized = readFile(createStorageD...
Pontone asked 30/3, 2022 at 9:46
2
Solved
Given json as follows where the structure of the payload object will vary:
{
"id": 1,
"displayName": "Success",
"payload": {
"someProperty": &q...
Boise asked 26/9, 2020 at 10:29
2
Solved
With GSON we used @SerializedName to parse JSON object which didn't have the same key to that of the variable name in Kotlin.
data class User (
@SerializedName("id")
long userId;
@SerializedNam...
Basir asked 8/6, 2020 at 2:33
1 Next >
© 2022 - 2024 — McMap. All rights reserved.