Thread
#serialization
    e

    ehubbard

    4 years ago
    Trying to get serialization going — but am running into what seems to be a basic problem. Using gradle to build.. but when I try to serialize a real simple data class… I get kotlinx.serialization.SerializationException: Can’t locate default serializer for class class kotlin.Any
    By basic.. meaning I’m missing something basic.. should that default serializer be added at compile time? or is something like my runtime classpath missing a library?
    buildscript {
        ext.kotlin_version = '1.2.21'
        ext.serialization_version = '0.4.1'
        repositories {
            mavenCentral()
            jcenter()
            maven { url "<https://kotlin.bintray.com/kotlinx>" }
        }
        dependencies {
            classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
            classpath "org.jetbrains.kotlinx:kotlinx-gradle-serialization-plugin:$serialization_version"
        }
    }
    apply plugin: 'kotlin'
    apply plugin: 'kotlinx-serialization'
    dependencies {
        compile "org.jetbrains.kotlinx:kotlinx-serialization-runtime:$serialization_version"
        compile "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
    s

    sandwwraith

    4 years ago
    Are you really trying to serialize
    kotlin.Any
    ? Types needed no be known statically when you try to obtain serializer from them
    e

    ehubbard

    4 years ago
    Nope.. I’m not trying to serialize Any.. hence my confusion.. its gotta be some sort of configuration problem with the plugin… but… where..
    I gave up for a few days.. looking at it again now…
    Problems parsing {“type”:“VELOCITY”,“velocity”:{“x”:0,“y”:-4468.8,“Z”:0},“login”:null,“ping”:null} kotlinx.serialization.SerializationException: Any type is not supported at kotlinx.serialization.ElementValueInput.readValue(Serialization.kt:399) at kotlinx.serialization.KInput.readValue(Serialization.kt:226)
    val mfc :MessageFromClient = JSON.parse<MessageFromClient>(command)
    @Serializable data class MessageFromClient(val type:String, @Optional val velocity: Velocity?=null, @Optional val login:Login?=null, @Optional val ping😛ing?=null )
    okay… so yes brain dead and a few days to look away helped..😃 I was missing a serializable annotation on one of the sub-objects