marcinmoskala
03/26/2018, 6:22 PMchristophsturm
03/28/2018, 10:56 AMneworldlt
03/28/2018, 4:11 PM<https://github.com/Kotlin/kotlinx.serialization/tree/sourcegen>
. I am curious, is it because plugin isn’t a solution after all?elizarov
04/10/2018, 1:22 PMhastebrot
04/13/2018, 9:56 AMrrva
04/26/2018, 5:50 PMniklas
04/27/2018, 8:04 AMdynamic
objects https://github.com/Kotlin/kotlinx.serialization/blob/master/docs/runtime_usage.md#dynamic-object-parser-js-only
now I am wondering how I would serialize to a dynamic
object. I guess I can do this:
val jsonString = kotlinx.serialization.json.JSON.stringify(kotlinData)
val dataAsPureJs = kotlin.js.JSON.parse(jsonString)
BorzdeG
04/29/2018, 12:12 PMchristophsturm
05/24/2018, 12:09 PMbissell
05/26/2018, 7:54 PMString
or Long
in Kotlin? My first thought was to attempt to read the field as a Number, and then if that fails (presumably because the field is another JSON type), then try to read it as String. But I haven't been able to write a method that can do this.bissell
05/28/2018, 12:40 AM5
and "5"
and into fields of int/String type and the parser will not generate an error. I dunno, seems to me like "the wrong thing" to dochristophsturm
06/01/2018, 5:08 PMjw
06/04/2018, 9:33 PMrr/kotlinx.serialization
branch of the kotlin repo?hastebrot
06/07/2018, 2:57 PM@type
entry? https://github.com/Kotlin/kotlinx.serialization/pull/132sandwwraith
07/13/2018, 3:04 PMkotlinx.serialization
version 0.6.0 just has been released. Short highlights:
- Kotlin/Native limited support via JSON parser and JSON abstract syntax tree
- Support of @SerialName
and @SerialInfo
annotations on classes
- Auto-assigning protobuf ids using field index, if @SerialId
is missing on property.
Full changelog: https://github.com/Kotlin/kotlinx.serialization/blob/master/CHANGELOG.md#v060--2018-07-13
_Note_: 0.6.0
is a release for stable 1.2.5x
compiler versions. If you’re using eap compiler, you should update to 0.6.1-SNAPSHOT
, which has the same feature set.neworldlt
07/19/2018, 7:56 PM0.5.0
it worked well. With 0.6.0
compile is crashing with Can't locate polymorphic serializer definition
Edouard Goossens
07/20/2018, 7:58 PMEdouard Goossens
07/29/2018, 12:04 PMkhairil.ushan
08/01/2018, 12:01 PMException in thread "ForkJoinPool.commonPool-worker-1" kotlinx.coroutines.experimental.CompletionHandlerException: Exception in completion handler InvokeOnCompletion[InvokeOnCompletion@55c536ef] for DeferredCoroutine{Completed}@48184828
at kotlinx.coroutines.experimental.JobSupport.notifyCompletion(JobSupport.kt:1022)
at kotlinx.coroutines.experimental.JobSupport.completeUpdateState(JobSupport.kt:229)
at kotlinx.coroutines.experimental.JobSupport.updateState(JobSupport.kt:157)
at kotlinx.coroutines.experimental.JobSupport.makeCompletingInternal(JobSupport.kt:568)
at kotlinx.coroutines.experimental.JobSupport.makeCompletingOnce$kotlinx_coroutines_core(JobSupport.kt:552)
at kotlinx.coroutines.experimental.AbstractCoroutine.resume(AbstractCoroutine.kt:103)
at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:41)
at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:41)
at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:41)
at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:41)
at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:41)
at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:41)
at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:41)
at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:41)
at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:41)
at kotlin.coroutines.experimental.jvm.internal.CoroutineImpl.resume(CoroutineImpl.kt:41)
at kotlinx.coroutines.experimental.DispatchedTask$DefaultImpls.run(Dispatched.kt:150)
at kotlinx.coroutines.experimental.AbstractContinuation.run(AbstractContinuation.kt:19)
at java.util.concurrent.ForkJoinTask$RunnableExecuteAction.exec(ForkJoinTask.java:1402)
at java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:289)
at java.util.concurrent.ForkJoinPool$WorkQueue.runTask(ForkJoinPool.java:1056)
at java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1692)
at java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:157)
Caused by: java.lang.NoClassDefFoundError: kotlinx/serialization/json/JSON
at com.khairilushan.mpp.datasource.ProjectDataSource$Network$searchProject$$inlined$requestJson$1.invoke(NetworkService.kt:59)
at com.khairilushan.mpp.datasource.ProjectDataSource$Network$searchProject$$inlined$requestJson$1.invoke(NetworkService.kt:10)
at io.ktor.common.client.Promise.complete(utils.kt:20)
at io.ktor.common.client.JvmUtilsKt$promise$$inlined$also$lambda$1.invoke(JvmUtils.kt:13)
at io.ktor.common.client.JvmUtilsKt$promise$$inlined$also$lambda$1.invoke(JvmUtils.kt)
at kotlinx.coroutines.experimental.InvokeOnCompletion.invoke(JobSupport.kt:906)
at kotlinx.coroutines.experimental.JobSupport.notifyCompletion(JobSupport.kt:1018)
... 22 more
Caused by: java.lang.ClassNotFoundException: kotlinx.serialization.json.JSON
at java.net.URLClassLoader.findClass(URLClassLoader.java:381)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
... 29 more
apomelov
08/09/2018, 10:49 AM@Serializable
abstract class Tree(open val health: Int = 100)
@Serializable
class Willow(override val health: Int = 95) : Tree(health)
But I was surprised when saw the JSON:
["Willow",{"health":95,"health":95}]
Actually, I'm not sure it's a valid one... How can I handle inheritance with serialization?vpriscan
08/15/2018, 11:32 AMvpriscan
08/15/2018, 2:01 PMfun load(input: KInput): MyObject {
val maybeString = input.readNullable(StringSerializer)
return if (maybeString != null) {
//do something with string that results in creating of MyObject
} else {
input.read<MyObject>()
}
}
alex009
08/16/2018, 5:35 AMAlbert
08/16/2018, 9:49 AMMap<String, Any>
but I can't not find how. I tried a specific implementation for that particular class like so:
output.write(
(StringSerializer to StringSerializer).map,
mapOf(
"access_token" to obj.accessToken,
"token_type" to obj.tokenType
)
)
output.write(
(StringSerializer to IntSerializer).map,
mapOf(
"expires_in" to obj.expiresIn
)
)
But this results into 2 JSON documents. I have the feeling I am overlooking a particular Serializer
Mohit Gurumukhani
08/20/2018, 9:28 PMMohit Gurumukhani
08/23/2018, 9:00 PM-keep class kotlinx.serialization.json.*
to proguard-rules.pro. Is this intended? Or is there a better way?grandstaish
09/10/2018, 10:08 AMNikky
09/10/2018, 10:27 PMwriteStringElementValue
or similar,
i hoped to be able to use the infrastructure to support writing customized JSON objectsNikky
09/12/2018, 11:33 AMserializerByTypeToken
does not work on parameterized types because it passes the wildcardtype on to the next (recursive) call
for my ktor PR i fixed it like so: https://github.com/NikkyAI/ktor/blob/2ace29d5478d6f51278b47934884858f17e78c00/ktor-client/ktor-client-features/ktor-client-json/ktor-client-json-jvm/src/io/ktor/client/features/json/serializer/SerialHelperJvm.kt#L24-L29
should i make a PR for this ?Nikky
09/12/2018, 9:54 PM