Questions tagged [kotlinx]
44 questions
3
votes
1 answer
how to compile kotlinx.serialization libraries on the command line?
This is very close to what I'm trying to accomplish. How to compile and run kotlin program in command line with external java library
I really want to learn how to compile and run simple code that includes libraries but am getting a bit lost when it…

Cody
- 117
- 1
- 13
3
votes
1 answer
Receiving NoClassDefFoundError when invoking generated serializer() method
I’m getting a NoClassDefFoundError when trying to invoke the Foo.serializer() method on a @Serializable class.
Here's my test case:
@Serializable
data class Foo(val data: String)
val jsonString = json.stringify(
Foo.serializer(), // <= Error…

rharter
- 2,495
- 18
- 34
3
votes
1 answer
Add onClick to Button in Ktor with Kotlinx
I am currently trying out Ktor. But it already fails on registering a onClickListener to the button.
I am just wondering because the onClick extends from String. If I click on the onClick the Code I get is this one:
var…

Torben G
- 750
- 2
- 11
- 33
2
votes
1 answer
How to compare actual and expected serialization result in kotlinx?
Note: I'm completely new to the Kotlin / JUnit ecosystem, so please bear with me if the question is missing something basic.
I'm working on a JSON-based file format. In the unit/integration tests, I'd like to check that the serialization produces…

bluenote10
- 23,414
- 14
- 122
- 178
2
votes
1 answer
Kotlinx serialization - How to write a data class for an unknown field name
I try to write a data class for the following JSON response from a public API:
{
"error": [],
"result": {
"AAVE": {
"aclass": "currency",
"altname": "AAVE",
"decimals": 10,
"display_decimals": 5
},
"ADA": {
…

Peter Renz
- 23
- 5
2
votes
0 answers
Preventing HTML encoding in kotlinx.html DSL
I am using kotlinx.html DSL to generate an HTML DIV. One of the DIV's attributes is a URL with & in it. e.g. Parameter url below is https://www.example.com?a=1&b=2
fun createDiv(url: String): DIV.() -> Unit {
return {
attributes["data-url"] =…

Big Pumpkin
- 3,907
- 1
- 27
- 18
2
votes
1 answer
import kotlinx.android.synthetic failed : Android studio doesn't find it but I can run the app
I found a lot of things about the subject, but not enough to fix it, so here I go.
I just arrived on a new project and they have a heavy problem :
import kotlinx.android.synthetic
is unresolved by Android Studio. The project runs, and there is no…

Romain Huber
- 205
- 4
- 14
1
vote
1 answer
Can I get a fixed clock in kotlinx time?
I'm trying to transition my code to use kotlinx.datetime instead of the java.time library as I'd like to make use of the serialization benefits of the kotlinx library (it can serialize instant using the @Serialize annotation).
However, i have tests…

willjsporter
- 55
- 4
1
vote
0 answers
How convert Data class to JsonElement in kotlinx
I'm trying to convert a kotlin dataclass to a JsonElement, is there a way to do it using kotlin?
@Serializable
data class SubjectContext(
val name: String,
var programContext: Properties? = null
)
@Serializable
data class Properties(
…

C.Meza
- 11
- 3
1
vote
1 answer
Unresolved reference kotlinx in Kotlin project
This line:
import kotlinx.coroutines.*
Gives me Unresolved reference: kotlinx error.
My project creation process is very basic:
In Intellij Idea: New project -> Kotlin -> JVM
My project structure:
Maybe I need to configure something…

vytaute
- 1,260
- 4
- 16
- 36
1
vote
2 answers
Is there a way to use Kotlinx serialisation in an Android savedInstanceState Bundle?
It looks like the compiler doesn't want to use Kotlinx serialized classes in putSerializable and getSerializable.
It says Type mismatch: inferred type is MyViewModel.SavedState but Serializable? was expected.
In my Activity:
override fun…

KotlinKiddo
- 13
- 4
1
vote
1 answer
kotlinx de/serialization sealed class/enum
Writing chat app using kotlin,
historically from nodejs I have websocket json objects in/output format:
{"action": "join:chatroom", "payload", "chatroom-name"}
{"action": "leave:chatroom", "payload", "chatroom-name"}
{"action": "message", "payload",…

Roman Vasilyev
- 149
- 4
- 12
0
votes
0 answers
Kotlinx SerialName not as a constant
I am parsing a json object and there multiple values for same field for the different languages.
For example:
"subtitle_en": "Hello World",
"subtitle_de": "Hallo Welt"
I want to extract the subtitle depending on the language I have on my device.
I…

guerdaa
- 157
- 1
- 7
0
votes
0 answers
Kotlinx Serializer for List instead of just T at Serializable annotation of field
So I have this class to for Json deserialization:
@Serializable
data class NetworkUser(
@SerialName("id")
val id: Long,
...
@Serializable(RoleSerializer::class)
@SerialName("role")
val role: List
)
Serializer for…

user924
- 8,146
- 7
- 57
- 139
0
votes
1 answer
How to handle Any serialization with kotlinx serialization
I have a JSON response with a parameter which may be of different types depending on the enum value of another parameter.
Example JSON:
[
{
"type":1,
"value":"String"
},
{
"type":2,
"value": 4
},
…

Marc
- 49
- 8