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
  • t

    thevery

    12/20/2018, 9:31 PM
    Is it a known issue for native?
    error: compilation failed: Unable to resolve exported type ExternalType(hash='8694429315213666092', name='kotlinx.serialization.KSerializer')
    s
    • 2
    • 5
  • n

    Nikky

    12/24/2018, 9:03 PM
    is there any plans for Comments in Json ?
    @Comment("what the thing does")
    on a filed and
    Json(enableComments = true)
    to allow parsing and serializing them
    🇳🇴 1
    s
    o
    g
    • 4
    • 9
  • n

    Nikky

    12/25/2018, 1:01 AM
    which crashes because the
    SerialClassDescImpl
    rather throws a
    MissingDescriptorException
    than returning a
    StringDescriptor
    s
    • 2
    • 5
  • a

    Alexander

    12/25/2018, 7:40 AM
    Are there any plans to make
    kotlinx.serialization.json.Parser
    public? I want to parse json stream and there are jvm-only solutions. Think it would be nice to have multiplatform streaming parser.
    g
    s
    • 3
    • 6
  • s

    serebit

    12/25/2018, 4:38 PM
    Will HOCON support eventually be merged into the mainline runtime? Also, will the existing HOCON artifact ever get native support?
    s
    • 2
    • 1
  • r

    rrader

    12/26/2018, 1:57 PM
    Does this library supports "Polymorphic classes" https://github.com/cbeust/klaxon#polymorphic-classes ?
    s
    • 2
    • 4
  • r

    rrader

    12/26/2018, 2:25 PM
    How validation is done? for example we need to check that a property length should not be more than 100 characters
    s
    • 2
    • 9
  • r

    rrader

    12/30/2018, 7:42 PM
    Is it possible to configure that in Kotlin classes have properties in camel case, but on serialization/deserialization json properties are in snake case?
    q
    g
    • 3
    • 4
  • q

    qlitzler

    12/31/2018, 1:56 AM
    Hello, I have this scenario where I need to deserialize a JSON that can have a different type for the same key, depending on a server response I can't control. Example:
    { "myKey": true } // First server response
    { "myKey": "someValue" } // Second server response
    I don't know in advance what kind of type the value will be, so I came up with this solution. I would like your professional opinion: Is there a better way to do it ? Can it be improved ? If you find it alright, I'm leaving the code snippet for those who might run into the same use case.
    Untitled.kt
    v
    • 2
    • 1
  • q

    qlitzler

    12/31/2018, 2:08 AM
    Also, I found something interesting. I initially wrote the test like this (see code snippet attached), but it failed with the following error message:
    java.lang.AssertionError: 
    Expected :{"primitive": 0}
    Actual   :{"primitive":0}
    As you can see, there's an additional space between the semicolon and the value when I serialize the json using
    json { "primitive" to 0 }.toString()
    , compared to
    JSON.stringify(serializer, obj)
    . Is this intentional ? It seems to me that both should have the exact same output
    -.kt
    v
    • 2
    • 1
  • s

    serebit

    01/08/2019, 10:06 PM
    Deserializing mutable collections. When will this be possible?
    v
    • 2
    • 2
  • n

    Nikky

    01/09/2019, 10:08 PM
    Fuel has not seen releases for quite a while.. best to use jitpack there
    s
    • 2
    • 6
  • n

    Nikky

    01/11/2019, 12:23 AM
    its created by kotlinx-serialization.. every class that is
    @Serializable
    has this function to get its serializer
    s
    i
    • 3
    • 6
  • t

    thevery

    01/13/2019, 2:35 PM
    @sandwwraith any plans for Gradle 4.10 compatible release of serialization? Right now you have to pick either sqldelight (4.10) or serialization/ktor/coroutines (4.7)
    s
    t
    n
    • 4
    • 5
  • a

    alexfacciorusso

    01/14/2019, 9:48 AM
    Hello everyone! Some days ago I wrote this post on #ktor, but I still can’t find a solution. Does anyone have a clue about it? https://kotlinlang.slack.com/archives/C0A974TJ9/p1547224415261500
    s
    • 2
    • 1
  • j

    JoakimForslund

    01/17/2019, 11:04 AM
    Is it currently impossible to serialize inherited classes for iOS? Seems to work great with jvm/js. The README.md kind of states it, but it does not really say that inheritance does not work. Anyone knows?
    j
    s
    • 3
    • 8
  • n

    nikolaymetchev

    01/17/2019, 1:07 PM
    How hard would it be to have
    @Serializable(with = ...)
    work at the top level
    @Serializer(forClass = CustomData::class)
    class CustomDataSerializer : KSerializer<CustomData> {...
    }
    
    @Serializable(with = CustomDataSerializer::class)
    data class CustomData(val data: String)
    
    fun m() {
      val x: KSerializer<CustomData> = CustomData.serializer() // this doesn't compile
    }
    s
    • 2
    • 2
  • c

    charleskorn

    01/20/2019, 10:02 PM
    I’ve continued to expand kaml (https://github.com/charleskorn/kaml), my YAML provider for kotlinx.serialization. It now supports serializing (Kotlin objects -> YAML string) and deserialization has been battle tested in a production application. Any suggestions, feedback or bug reports are welcome 🙂
    👍 2
    🎉 1
    s
    • 2
    • 2
  • a

    Ashley Figueira

    01/22/2019, 9:51 AM
    Anyone has come up with this issue? Cannot use @Serializable as the ios target fails to compile. I have added the dependency of serialization to the ios target version 0.9.1 but on my gradle it still complains ...
    s
    • 2
    • 9
  • d

    Davide Giuseppe Farella

    01/22/2019, 2:41 PM
    Any way to avoid
    @ImplicitReflectionSerializer
    to spread all over my codebase like a cancer? 😅
    ✔️ 1
    s
    • 2
    • 2
  • t

    thevery

    01/23/2019, 10:24 PM
    Is 0.10.0 on the release pipeline or we need to wait a bit longer?
    • 1
    • 1
  • n

    Nikky

    01/24/2019, 4:44 AM
    after updating to kotlin 1.3.20 (dependencies and idea plugin) calls to .serializer() are marked red
    j
    t
    • 3
    • 3
  • s

    sandwwraith

    01/24/2019, 9:51 AM
    📣 kotlinx.serialization
    v0.10.0
    has been released! This release is binary compatible with Kotlin/Native 1.3.20. Important highlights and breaking changes: • Gradle metadata version was bumped to 0.4, so you need to upgrade Gradle in your project to 4.8 or higher (recommended is 4.10) to be able to resolve K/N dependencies • Maven serialization plugin coordinates were changed to match other compiler maven plugins. Now it is `kotlin-maven-serialization`: https://search.maven.org/artifact/org.jetbrains.kotlin/kotlin-maven-serialization/1.3.20/jar. Issue with Maven import (https://github.com/Kotlin/kotlinx.serialization/issues/307) has also been resolved. • This release contains all changes from 0.10.0-eap-1, including JSON->Json renaming, ability to skip default values, ability to inspect descriptors tree, and almost feature-full compiler plugin for Kotlin Native. Full changelog: https://github.com/Kotlin/kotlinx.serialization/blob/master/CHANGELOG.md#0100--2019-01-22
    🎉 14
    👍 10
    g
    q
    • 3
    • 4
  • n

    Nikky

    01/24/2019, 9:10 PM
    is there a known fix for the problems caused when a typealias is pointing a nonexistant class? like
    Json
    replacing
    JSON
    i cannot com;ile any dependency using 0.9.1 with my program using 0.10.0
    s
    o
    • 3
    • 4
  • j

    JoakimForslund

    01/28/2019, 8:44 AM
    Im getting
    java.lang.IllegalStateException: Backend Internal error: Exception during code generation
    Cause: Back-end (JVM) Internal error: Serializer for element of type HashMap<String, String> has not been found.
    To use context serializer as fallback, explicitly annotate element with @ContextualSerializer
    Since the latest serialization_version=0.10.0 Two things, there seems to be no annotation called
    @ContextualSerializer
    to import, there is a
    @ContextualSerialization
    however. Using the latter before the HashMap seems to give:
    No direct method <init>(Lkotlin/reflect/KClass;Lkotlinx/serialization/KSerializer;Lkotlinx/serialization/KSerializer;)V in class Lkotlinx/serialization/ContextSerializer; or its super classes (declaration of 'kotlinx.serialization.ContextSerializer'
    Any ideas?
    s
    • 2
    • 2
  • j

    josephivie

    01/28/2019, 8:13 PM
    Is there any way to create an annotation instance? I've got a weird situation where it would be nice to have.
    n
    • 2
    • 17
  • h

    hallvard

    01/29/2019, 3:35 PM
    Folks, where are the instructions for use and/or extension of the MapLikeSerializer and HashMapSerializer classes?
    s
    • 2
    • 4
  • j

    josephivie

    01/30/2019, 7:35 AM
    There's no encode/decode for byte strings, right? I'm thinking I'll make a PR for it.
    encodeBytes()
    and
    decodeBytes()
    ? Kotlin type
    ByteArray
    ? Or is this something that is deliberately left out of the library?
    s
    • 2
    • 1
  • m

    Mate

    01/30/2019, 12:58 PM
    Q: I have a serializable data class Foo which has two properties a, b
    @Serializable
    data class Foo(
        val a: String,
        val b: List<String>
    )
    I'd like to handle read/write asymmetrically in this case (using JSON): - For read I'd like to read both a and b properties from json string - For write however I'd like to serialize only b to json string I've tried the Mapper to convert this to a map remove the unwanted key, but then I could not find a way to serialize the Map<String, Any> What do you think would be the best solution for this case? Something like @Transient(In|Out|InOut) would be great 🙂
    j
    • 2
    • 4
  • j

    jw

    01/31/2019, 4:37 AM
    there's a polymorphic serializer now
    h
    s
    t
    • 4
    • 9
Powered by Linen
Title
j

jw

01/31/2019, 4:37 AM
there's a polymorphic serializer now
h

hallvard

01/31/2019, 8:25 AM
I only see it for the jvm (not for common, not for js). Am I missing something again?
j

jw

01/31/2019, 1:57 PM
There's a PR for MPP. Didn't realize it hadn't landed yet
h

hallvard

01/31/2019, 4:48 PM
I suppose you're referring to https://github.com/Kotlin/kotlinx.serialization/pull/268. Since you seem to have been believing it was already «out there», should we be optimistic about some imminent release?
j

jw

01/31/2019, 5:15 PM
Ah I have no idea. I'm just following over email so it's easy to lose track of the state of things.
h

hallvard

01/31/2019, 5:24 PM
OK, thanks, Jake. Maybe @sandwwraith would know ...
s

sandwwraith

01/31/2019, 6:00 PM
Well, it is close to be ready
👍 2
h

hallvard

01/31/2019, 8:18 PM
Nice. I'll stop my efforts to patch up something that only nearly works, and wait for the complete solution!
s

sandwwraith

01/31/2019, 8:54 PM
(but it doesn't mean 'next week')
t

turansky

02/26/2019, 1:10 PM
Does it mean 'this week'?
View count: 7