Feature request: Support kotlinx.serialization

kotlinx.serialization (docs) is the first party JSON encoder/decoder from Jetbrains.

Source here: GitHub - Kotlin/kotlinx.serialization: Kotlin multiplatform / multi-format serialization

Please provide a com.couchbase.client.kotlin.codec.JsonSerializer for kotlinx.serialization

1 Like

Made the request here https://issues.couchbase.com/browse/KCBC-101

1 Like

A couple of Kotlin performance issues stand in the way of a great integration:

In the meantime, we can do an 80% solution that works only for non-nullable types. For example, this would work:

val foo = collection.get("foo").contentAs<Foo>()

But the following would fail if the document content is a JSON null:

val foo = collection.get("foo").contentAs<Foo?>()

And the following would fail if the Bar in question is null/absent:

val foo = collection.get("foo").contentAs<Foo<Bar?>>()

Let me know how you feel about this as a stopgap measure until the performance issues are resolved (hopefully in Kotlin 1.8).

Thanks,
David

1 Like

Couchbase Kotlin SDK 1.1.0 is now available. It has an experimental KotlinxSerializationJsonSerializer, with the caveats mentioned above.

1 Like

Very cool; I look forward to trying this out.

-Aaron