https://kotlinlang.org logo
Docs
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
  • j

    jw

    09/13/2018, 3:13 PM
    is 0.6.2 for use with 1.2.70 only?
    s
    • 2
    • 1
  • n

    Nikky

    09/14/2018, 10:41 AM
    not tagged / released on github.. that confused me for a bit before
    s
    l
    • 3
    • 2
  • j

    josephivie

    09/20/2018, 11:34 PM
    Ah, never mind, it’s just that the README isn’t updated yet.
    s
    • 2
    • 2
  • s

    sandwwraith

    09/21/2018, 2:38 PM
    decodeElementIndex
    indeed produces element index. You need to switch over it and then select proper property to decode
    a
    • 2
    • 7
  • h

    hiperbou

    09/26/2018, 3:01 PM
    Hello, I'm using Kotlin 1.2.71-release-IJ2018.2-1, IntellJ 2018.2.4 #IC-182.4505.22, with a Javascript project without Gradle, and I always get an error with the serialization plugin for IntelliJ when trying to compile my project. The direct link to the Latest release (1.2.70) in the github readme.md "doesn't work" and I tried installing different versions, 6.2, 6.1... but all of them are failing.
    s
    • 2
    • 4
  • v

    voddan

    09/27/2018, 12:08 PM
    In particular I can't find
    kotlinx-gradle-serialization-plugin:0.8.1-rc13
    in the repos
    s
    • 2
    • 9
  • k

    kartikpatodi

    10/02/2018, 8:23 PM
    How can we create a custom serializer?
    c
    • 2
    • 1
  • t

    tylerwilson

    10/02/2018, 8:39 PM
    Any thoughts or work to have this serializer plugged into retrofit2? Might be an interesting test case at least…
    s
    • 2
    • 2
  • t

    thevery

    10/03/2018, 3:59 PM
    What is the current status of serialization+native+multiplatform? Is workaround for plugin path still required?
    s
    • 2
    • 5
  • w

    wcaokaze

    10/04/2018, 12:32 PM
    Hi. I cannot find any functions to use Reader/Writer (nor IOStream). Are they not available?
    s
    • 2
    • 2
  • c

    christophsturm

    10/04/2018, 1:49 PM
    with serialization being part of kotlin 1.3, does that mean we can start using it in apps that ship soon?
    t
    v
    • 3
    • 2
  • t

    turansky

    10/04/2018, 9:18 PM
    JSON
    {
      "data": [
        {
          "id": "x1_1",
          "type": "x1"
        },
        {
          "id": "x2_1",
          "type": "x2",
          "children": [
            {
              "id": "y1_1",
              "type": "y1"
            },
            {
              "id": "y2_1",
              "type": "y2",
              "connectedItems": [
                "x1_1"
              ]
            }      
        }
      ]
    }
    Data classes
    interface X {
      val id: String
    }
    
    interface Y {
      val id: String
    }
    
    data class D1(data: Array<X>)
    
    data class X1(id): X
    data class X2(id, children: Array<Y>): X
    
    data class Y1(id): Y
    data class Y2(id, connectedItems): Y
    If there any possibility to realize deserialization for this case (according
    type
    field)?
    s
    • 2
    • 22
  • n

    Nikky

    10/06/2018, 5:20 PM
    i have a annoying api where a timestamp can be a string or a long, is there a way to tell in the deserializer what JSON type a field is ? number literal or string literal or is ther tryParseLong() or similar ?
    s
    • 2
    • 1
  • j

    Jonas Bark

    10/09/2018, 6:18 PM
    https://github.com/JetBrains/kotlinconf-app/blob/master/common/src/commonMain/kotlin/org/jetbrains/kotlinconf/api/KotlinConfApi.kt#L16 seeing the Sourcecode of the KotlinxSerializer it does not support List<Whatever>::class as mapping argument and would internally use JSON.parse instead of JSON.parseList anyway. Is anyone aware of a smart way to support mapping of Lists using JsonFeature?
    t
    s
    • 3
    • 5
  • v

    ValV

    10/10/2018, 11:47 AM
    What happened to
    kotlinx.serialization
    ? I have installed IDEA plugin, added and updated Maven repositories, but
    <artifactId>kotlinx-maven-serialization-plugin</artifactId>
                        <version>${serialization.version}</version>
    are not found
    s
    • 2
    • 13
  • n

    Nikky

    10/10/2018, 5:18 PM
    just wanted to ask.. the bug where automatically finding the serializers for types in another submodule, is there a better solution than adding
    @Serializable(with=)
    ? that also does not work with lists afaik
    s
    • 2
    • 10
  • f

    fkrauthan

    10/10/2018, 6:41 PM
    Forwarding my question and thread here as this should be the better place for it.
    s
    • 2
    • 2
  • t

    theodorosploumis

    10/11/2018, 8:56 AM
    https://stackoverflow.com/jobs/204900/drupal-developer-ibm (By IBM at Bucharest, Romania)
    v
    s
    • 3
    • 3
  • r

    r4zzz4k

    10/12/2018, 2:53 PM
    Is there any technical reason
    kotlinx-serialization-runtime-native
    isn't provided for
    linux
    and other targets aside from
    ios
    /
    macos
    or it's just nobody checked if it's working as-is?
    s
    t
    • 3
    • 3
  • n

    Nikky

    10/14/2018, 8:49 PM
    something else.. could you move or push a additional artifact to
    kotlinx-serialization:kotlinx-serialization
    ? that would be the default location gradle looks for when adding the kotlinx repo to
    pluginManagement
    and resolving
    id("kotlinx-serialization") version Versions.serialization
    i guess thats just a concern for pre 1.3, but the same thing basically for all the gradle plugins in kotlinx (not sure if there are or how many)
    s
    • 2
    • 2
  • t

    thevery

    10/17/2018, 10:34 AM
    @sandwwraith is there any updated doc on writing custom serializer? This one uses deprecated code and doesn't compile: https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/custom_serializers.md#customizing
    s
    • 2
    • 8
  • t

    thevery

    10/17/2018, 1:46 PM
    Am I right that
    @Polymorphic
    doesn't work with generics well?
    class ParserTest {
        open class Field
    
        @Serializable data class FieldB(val a: String, val b: Int) : Field()
    
        @Serializable data class FieldC(val a: String, val b: Int) : Field()
    
        @Serializable data class Data(@Polymorphic val a: List<Field>)
    
        @Test
        fun testPoly() {
            val obj = JSON.parse<Data>("""{"a":[{a:"a", b: 1}]}""")
            println("obj = ${obj}")
        }
    }
    produces
    java.lang.IllegalArgumentException: JSON at 6: Expected '[, kind: kotlinx.serialization.UnionKind$POLYMORPHIC@33e5ccce'
    s
    • 2
    • 4
  • v

    ValV

    10/18/2018, 4:27 PM
    I have
    @Serializable data class MyData (val name: String, val value: Any)
    and works pretty good with
    MyData.serializer()
    until
    value
    is
    java.util.Date
    . What is the better way to solve it? Write custom serializer like in https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/custom_serializers.md ?
    ❌ 1
    • 1
    • 4
  • t

    thevery

    10/18/2018, 11:22 PM
    Finally I've got working version for JVM but native fails with
    exception: kotlin.NotImplementedError: An operation is not implemented: Serializable classes with inheritance
    . It there any workaround for this?
    • 1
    • 1
  • n

    Nikky

    10/19/2018, 8:47 AM
    i am upgrading from 1.2 to 1.3 and IDE and gradle tell me everything is broken, did
    serialClassDesc
    or annotations renamed too ?
    t
    • 2
    • 1
  • p

    pablisco

    10/20/2018, 7:26 AM
    Yeah, that's the ideal scenario. I guess if the order is reversed it's the incorrect format 🙃
    n
    • 2
    • 4
  • n

    Nikky

    10/20/2018, 9:52 AM
    this guide should probably be updated (function names etc) https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/custom_serializers.md
    :yes: 2
    t
    • 2
    • 1
  • p

    pablisco

    10/20/2018, 5:14 PM
    Another kinda related question. Is there a way to get the name of the current element from the KInput? I guess this may only apply to JSON though.
    s
    • 2
    • 6
  • j

    jcechace

    10/22/2018, 12:35 PM
    Can somebody give me an example of how to use `kotlinx.serialization`: 0.8.3-rc13. With the kotlin-gradle dsl?
    n
    • 2
    • 7
  • j

    jcechace

    10/22/2018, 3:54 PM
    I guess
    PolicySerializer.list
    does the right thing, however I need to figure out how to register it
    n
    • 2
    • 2
Powered by Linen
Title
j

jcechace

10/22/2018, 3:54 PM
I guess
PolicySerializer.list
does the right thing, however I need to figure out how to register it
n

Nikky

10/22/2018, 4:26 PM
you do not register it.. you use that when you call json.parse(), the default is the try to get the right thing using reflection (on the jvm) bur because of type erasure it cannot give you a list of a specific type
so you have to provide it the serializer to use
View count: 3