https://kotlinlang.org logo
Join the conversationJoin Slack
Channels
100daysofcode
100daysofkotlin
100daysofkotlin-2021
advent-of-code
aem
ai
alexa
algeria
algolialibraries
amsterdam
android
android-architecture
android-databinding
android-studio
androidgithubprojects
androidthings
androidx
androidx-xprocessing
anime
anko
announcements
apollo-kotlin
appintro
arabic
argentina
arkenv
arksemdevteam
armenia
arrow
arrow-contributors
arrow-meta
ass
atlanta
atm17
atrium
austin
australia
austria
awesome-kotlin
ballast
bangladesh
barcelona
bayarea
bazel
beepiz-libraries
belgium
berlin
big-data
books
boston
brazil
brikk
budapest
build
build-tools
bulgaria
bydgoszcz
cambodia
canada
carrat
carrat-dev
carrat-feed
chicago
chile
china
chucker
cincinnati-user-group
cli
clikt
cloudfoundry
cn
cobalt
code-coverage
codeforces
codemash-precompiler
codereview
codingame
codingconventions
coimbatore
collaborations
colombia
colorado
communities
competitive-programming
competitivecoding
compiler
compose
compose-android
compose-desktop
compose-hiring
compose-ios
compose-mp
compose-ui-showcase
compose-wear
compose-web
connect-audit-events
corda
cork
coroutines
couchbase
coursera
croatia
cryptography
cscenter-course-2016
cucumber-bdd
cyprus
czech
dagger
data2viz
databinding
datascience
dckotlin
debugging
decompose
decouple
denmark
deprecated
detekt
detekt-hint
dev-core
dfw
docs-revamped
dokka
domain-driven-design
doodle
dsl
dublin
dutch
eap
eclipse
ecuador
edinburgh
education
effective-kotlin
effectivekotlin
emacs
embedded-kotlin
estatik
event21-community-content
events
exposed
failgood
fb-internal-demo
feed
firebase
flow
fluid-libraries
forkhandles
forum
fosdem
fp-in-kotlin
framework-elide
freenode
french
fritz2
fuchsia
functional
funktionale
gamedev
ge-kotlin
general-advice
georgia
geospatial
german-lang
getting-started
github-workflows-kt
glance
godot-kotlin
google-io
gradle
graphic
graphkool
graphql
graphql-kotlin
graviton-browser
greece
grpc
gsoc
gui
hackathons
hacktoberfest
hamburg
hamkrest
helios
helsinki
hexagon
hibernate
hikari-cp
hire-me
hiring
hongkong
hoplite
http4k
hungary
hyderabad
image-processing
india
indonesia
inkremental
intellij
intellij-plugins
intellij-tricks
internships
introduce-yourself
io
ios
iran
israel
istanbulcoders
italian
jackson-kotlin
jadx
japanese
jasync-sql
java-to-kotlin-refactoring
javadevelopers
javafx
javalin
javascript
jdbi
jhipster-kotlin
jobsworldwide
jpa
jshdq
juul-libraries
jvm-ir-backend-feedback
jxadapter
k2-early-adopters
kaal
kafka
kakao
kalasim
kapt
karachi
karg
karlsruhe
kash_shell
kaskade
kbuild
kdbc
kgen-doc-tools
kgraphql
kinta
klaxon
klock
kloudformation
kmdc
kmm-español
kmongo
knbt
knote
koalaql
koans
kobalt
kobweb
kodein
kodex
kohesive
koin
koin-dev
komapper
kondor-json
kong
kontent
kontributors
korau
korean
korge
korim
korio
korlibs
korte
kotest
kotest-contributors
kotless
kotlick
kotlin-asia
kotlin-beam
kotlin-by-example
kotlin-csv
kotlin-data-storage
kotlin-foundation
kotlin-fuel
kotlin-in-action
kotlin-inject
kotlin-latam
kotlin-logging
kotlin-multiplatform-contest
kotlin-mumbai
kotlin-native
kotlin-pakistan
kotlin-plugin
kotlin-pune
kotlin-roadmap
kotlin-samples
kotlin-sap
kotlin-serbia
kotlin-spark
kotlin-szeged
kotlin-website
kotlinacademy
kotlinbot
kotlinconf
kotlindl
kotlinforbeginners
kotlingforbeginners
kotlinlondon
kotlinmad
kotlinprogrammers
kotlinsu
kotlintest
kotlintest-devs
kotlintlv
kotlinultimatechallenge
kotlinx-datetime
kotlinx-files
kotlinx-html
kotrix
kotson
kovenant
kprompt
kraph
krawler
kroto-plus
ksp
ktcc
ktfmt
ktlint
ktor
ktp
kubed
kug-leads
kug-torino
kvision
kweb
lambdaworld_cadiz
lanark
language-evolution
language-proposals
latvia
leakcanary
leedskotlinusergroup
lets-have-fun
libgdx
libkgd
library-development
linkeddata
lithuania
london
losangeles
lottie
love
lychee
macedonia
machinelearningbawas
madrid
malaysia
mathematics
meetkotlin
memes
meta
metro-detroit
mexico
miami
micronaut
minnesota
minutest
mirror
mockk
moko
moldova
monsterpuzzle
montreal
moonbean
morocco
motionlayout
mpapt
mu
multiplatform
mumbai
munich
mvikotlin
mvrx
myndocs-oauth2-server
naming
navigation-architecture-component
nepal
new-mexico
new-zealand
newname
nigeria
nodejs
norway
npm-publish
nyc
oceania
ohio-kotlin-users
oldenburg
oolong
opensource
orbit-mvi
osgi
otpisani
package-search
pakistan
panamá
pattern-matching
pbandk
pdx
peru
philippines
phoenix
pinoy
pocketgitclient
polish
popkorn
portugal
practical-functional-programming
proguard
prozis-android-backup
pyhsikal
python
python-contributors
quasar
random
re
react
reaktive
realm
realworldkotlin
reductor
reduks
redux
redux-kotlin
refactoring-to-kotlin
reflect
refreshversions
reports
result
rethink
revolver
rhein-main
rocksdb
romania
room
rpi-pico
rsocket
russian
russian_feed
russian-kotlinasfirst
rx
rxjava
san-diego
science
scotland
scrcast
scrimage
script
scripting
seattle
serialization
server
sg-user-group
singapore
skia-wasm-interop-temp
skrape-it
slovak
snake
sofl-user-group
southafrica
spacemacs
spain
spanish
speaking
spek
spin
splitties
spotify-mobius
spring
spring-security
squarelibraries
stackoverflow
stacks
stayhungrystayfoolish
stdlib
stlouis
strife-discord-lib
strikt
students
stuttgart
sudan
swagger-gradle-codegen
swarm
sweden
swing
swiss-user-group
switzerland
talking-kotlin
tallinn
tampa
teamcity
tegal
tempe
tensorflow
terminal
test
testing
testtestest
texas
tgbotapi
thailand
tornadofx
touchlab-tools
training
tricity-kotlin-user-group
trójmiasto
truth
tunisia
turkey
turkiye
twitter-feed
uae
udacityindia
uk
ukrainian
uniflow
unkonf
uruguay
utah
uuid
vancouver
vankotlin
vertx
videos
vienna
vietnam
vim
vkug
vuejs
web-mpp
webassembly
webrtc
wimix_sentry
wwdc
zircon
Powered by Linen
serialization
  • b

    bendb

    10/04/2019, 4:54 PM
    This is probably a layer 8 problem, but I'm stumped. I'm attempting to use kotlinx.serialization without taking a kotlin-reflect dependency in a multiplatform project. I'm trying to do a basic sanity check in a JVM unit test that this works, but am getting a
    NoClassDefFoundError
    in
    Json.<clinit>
    , which is indirectly trying to look up
    KPackage
    , a kotlin-reflect type. The test passes if I add a
    kotlin-reflect
    dependency. Is it the case that json support requires kotlin-reflect?
    n
    f
    +2
    • 5
    • 10
  • b

    bendb

    10/04/2019, 7:56 PM
    (it's building a
    Map<KClass<*>, KSerializer<*>>
    , which I believe does in fact require kotlin-reflect to materialize the entire KClass.
    k
    m
    • 3
    • 7
  • g

    groostav

    10/04/2019, 10:31 PM
    Are there any common ways of converting a
    KClass<T>
    + `value: String`into an instance of
    T
    , given that you know
    T
    is a reasonable value type (
    Double
    ,
    Int
    ,
    Enum
    , or
    String
    )?
    n
    s
    • 3
    • 4
  • n

    nimrod

    10/09/2019, 7:58 PM
    I have a
    Map<String, Any>
    and one of the values contains a
    Date
    instance. Is it possible to have a custom serializer in this case? In
    deserialize
    method I don't know how to decode it
    b
    • 2
    • 5
  • n

    Nikky

    10/12/2019, 5:19 PM
    can i not serialize `object`s ? it seems to not work in Polymorphic code in :thread-please:
    d
    f
    • 3
    • 8
  • s

    Shan

    10/14/2019, 11:00 PM
    Hey all. I'm trying to use this data class and getting this response:
    j.b.u: Can't locate argument-less serializer for class e.b.b.d.a (Kotlin reflection is not available). For generic classes, such as lists, please provide serializer explicitly.
    Can anyone confirm that this means I have to write my own serializer because it's using a
    Map
    ? Or is there a way to do this that I'm missing somewhere? I'm using this with a Ktor request.
    Untitled
    d
    • 2
    • 11
  • g

    ghedeon

    10/21/2019, 11:54 AM
    Might be a strange question but how do you write a serializer for
    kotlin.Result
    class? Let say I want to write a custom call adapter for Retrofit that wraps all my requests in
    Result
    class. Right now serialization converter is failing with
    Can't locate argument-less serializer for class kotlin.Result
    which sounds reasonable. How would one workaround this situation?
    s
    n
    • 3
    • 19
  • t

    Tyron Jung

    10/21/2019, 7:09 PM
    Hi all, does anyone know how to make a
    JsonConfiguration(classDiscriminator = "customType")
    work only for a particular class? For instance, let’s say I have something like:
    @Serializable
    data class MyClass(
      @Polymorphic
      val polymorphicA: PolymorphicA,
      @Polymorphic
      val polymorphicB: PolymorphicB
    )
    And I’m serializing/deserializing an instance of
    MyClass
    . I want to serialize/deserialize
    polymorphicA
    using the default
    classDiscriminator
    which is
    type
    . However, I want to serialize/deserialize
    polymorphicB
    using a custom
    classDiscriminator
    , say
    customType
    . I don’t think the steps outlined in https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/polymorphism.md#a-bit-of-customizing showcase that level of granularity (i.e. if a custom
    classDiscriminator
    is specified, it’s applied to all of
    MyClass
    , which is not what I want).
    d
    • 2
    • 3
  • m

    Marc Dietrichstein

    10/22/2019, 12:09 PM
    Hi everyone! Does anyone know if https://github.com/Kotlin/kotlinx.serialization is the offical repository for this project? I'm trying to find out if using kotlinx.serialization is viable in the long term. We're stuck on kotlin 1.3.31 due to issues with kotlinx.serialiation in our multi-platform project and I have no idea if/when they will be resolved. There are no answers in the github issue tracker for the problems that affect us. I was wondering if there is a better place to report issues since there is not much dev activity in the repository or issue tracker on github.
    r
    s
    l
    • 4
    • 17
  • r

    ribesg

    10/23/2019, 9:44 AM
    What do you do if you want to have a “summary” version of the same model, with the summary being the super class of the full model? I’ve got issues with constructor parameters not being properties etc
    • 1
    • 2
  • s

    Shan

    10/27/2019, 12:15 AM
    Hello. I'm trying to set up my Multiplatform project with Ktor and Kotlinx.Serialization. I see for Native code there is an artifact for each specific Native target, and also just a "native" one. Just wondering which one I should be using for my targets-- if I have to use each specific one or if I can just use the "native" artifact?
    b
    • 2
    • 2
  • z

    zjuhasz

    10/28/2019, 9:08 PM
    Is there any documentation on creating add-on formats for kotlinx.serialization? It looks like there are some community made additional formats.
    f
    • 2
    • 5
  • r

    Russell Cullen

    11/01/2019, 2:31 PM
    I'm deserializing a
    Date?
    from a
    String?
    using a custom
    KSerializer<Date>
    and it's working great, until the 3rd party API I'm using sends an empty string instead of null as expected. Is there a way to map this empty case to a null Date instead of a dummy-Date? It seems something like
    KSerializer<Date?>
    is not supported, is that correct?
    f
    k
    • 3
    • 6
  • a

    altavir

    11/01/2019, 5:35 PM
    OK, I am continuing struggle with custom serializers. I am building my own analog of PolymorphicSerializer for a class which explicitely contatins type of the value and then the value itself. Everything works, but the problem is that if I follow the examples, then the field which contains actual value lacks the descriptor. Is there a way to generate sum-of-types style descriptor for that field?
    d
    • 2
    • 2
  • a

    altavir

    11/03/2019, 10:33 AM
    I got stuck again with custom serializers. I have a rather simple external object, which has three number fields: x, y and z and I want to create a custom serizer that replaces zeros with missing values and vice versa. Here is what I've written. It produces correct output, but refuses to read because it expects additional openning
    {
    inside the object. What am I doing wrong?
    Point3DSerializer.kt
    d
    • 2
    • 4
  • d

    Davide Giuseppe Farella

    11/07/2019, 2:19 AM
    But I got this exception at build time:
    e: java.lang.AssertionError: Recursion detected on input: IMPORT_DIRECTIVE under LockBasedStorageManager@160c4e98 (TopDownAnalyzer for JVM)
    k
    • 2
    • 3
  • r

    Ryan Benasutti

    11/08/2019, 10:47 PM
    Is there still no support for serializing objects? Like the questions in these messages: https://kotlinlang.slack.com/archives/C7A1U5PTM/p1551795255021700 https://kotlinlang.slack.com/archives/C7A1U5PTM/p1570900761010800
    d
    f
    n
    • 4
    • 5
  • b

    bitkid

    11/12/2019, 10:43 AM
    i have problem when using type aliases for Map<String, List<String?>> .. i get a weird indexoutofboundsexception .. but it works when i just use the map. i know i found a ticket somewhere about this problem .. but i can't find it anymore. any ideas if this is going to be fixed soon?
    m
    • 2
    • 4
  • m

    Marc Reichelt

    11/17/2019, 6:05 PM
    Hey there! What is the easiest way to parse an ISO8601 date right now with kotlinx serialization?
    b
    e
    • 3
    • 28
  • s

    Slackbot

    11/18/2019, 11:17 AM
    This message was deleted.
    s
    i
    • 3
    • 2
  • o

    Ovsyannikov Alexey

    11/19/2019, 11:09 AM
    Hello. Today I have seen that Kotlin 1.3.60 was released and, as I remember, it is expected that Kotlinx serialization will have a new one version after 1.3.60 version release. Is there some information about dates of new release for kotlinx.serialization ?
    s
    • 2
    • 2
  • s

    sandwwraith

    11/19/2019, 1:11 PM
    📣 kotlinx.serialization
    0.14.0
    has been released! This release contains some breaking changes and requires Kotlin 1.3.60 to work on all platforms. Some highlights: • Support for tvOS and watchOS in all flavours (added in Kotlin/Native 1.3.60) • Special support for serializing Kotlin's `object`s and
    sealed class
    es. See updated docs: https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/polymorphism.md#sealed-classes. • Enums now should support
    @SerialName
    and other specific annotations (but they should be marked
    @Serializable
    ). Full changelog: https://github.com/Kotlin/kotlinx.serialization/blob/master/CHANGELOG.md#v0140--2019-11-19
    🎉 21
    f
    a
    t
    • 4
    • 12
  • t

    turansky

    11/20/2019, 6:56 PM
    > Special support for serializing Kotlin’s
    object
    Is there any example on this theme? What is use case for
    object
    ?
    z
    c
    +3
    • 6
    • 9
  • t

    toban

    11/26/2019, 2:57 PM
    So I’m working with an API that represents money as a decimal number in JSON, e.g.
    "amount":10.99
    . How would i serialize a
    BigDecimal
    or
    String
    representation to a JSON number without any intermediate conversion to a floating point number?
    j
    s
    • 3
    • 4
  • o

    Ovsyannikov Alexey

    11/27/2019, 7:29 AM
    Hello:) Is it possible to decode json element (especially - jsonobject) inside of deserialize method of serializer even when decode was not created inside Json StringFormat?
    k
    • 2
    • 2
  • m

    Max Raskin

    12/03/2019, 6:14 PM
    Hi, in a Kotlin MPP, is there a clean way of serializing a Map<String, Any> to a JSON string? I've tried doing it using kotlinx.serialization but it seems to support only classes annotated with @Serializable, am I missing something? Thanks 🙂
    c
    s
    s
    • 4
    • 4
  • d

    Davide Giuseppe Farella

    12/04/2019, 8:26 AM
    Using
    DraftSource.build(actionId = 0, messageId = "id")
    or also
    as DraftSource
    is failing with
    Can't locate argument-less serializer for class
    s
    • 2
    • 3
  • g

    Geert

    12/06/2019, 10:12 PM
    Can someone tell me whats wrong? It looks like the serializer doesnt recognize my Map<String,String>. Im getting an
    java.lang.InstantiationError: kotlinx.serialization.KSerializer
    error. Even when I use the Data(abc) nesting example from <https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/examples.md>
    s
    • 2
    • 4
  • h

    Hullaballoonatic

    12/07/2019, 12:51 AM
    if enum classes are inherently serializable, why doesn't it inherently have
    MyEnumClass::serializer
    ? should I annotate
    @Serializable
    enum class MyEnumClass { ... }
    so that I can access it?
    f
    • 2
    • 2
  • p

    Patrick Jackson

    12/10/2019, 2:02 AM
    Any known issues with using kotlinx.serialization from android tests ("instrumentation tests") ? https://stackoverflow.com/questions/59259167/kotlinx-serialization-not-working-on-androidtest
    s
    • 2
    • 2
Powered by Linen
Title
p

Patrick Jackson

12/10/2019, 2:02 AM
Any known issues with using kotlinx.serialization from android tests ("instrumentation tests") ? https://stackoverflow.com/questions/59259167/kotlinx-serialization-not-working-on-androidtest
s

Sergei Dubrov [JB]

12/11/2019, 8:15 AM
Did not find anything like that. Please report it at https://youtrack.jetbrains.com/issues/KT. Attaching or providing a link to your project will be extremely useful for issue investigation.
p

Patrick Jackson

12/11/2019, 9:03 PM
appears to be a restriction of the android build system. I am running androidTest against a debug buildType, and have enabled
minifyEnabled true
. I've tried setting proguard rules for the test apk but still no luck...still looking into it, but I don't think this is a kotlinx.serialization issue
:tnx: 2
View count: 4