Hi, When changing serialization version from 1.0-M...
# serialization
r
Hi, When changing serialization version from 1.0-M1-1.4.0-rc that was release with Kotlin 1.4.0 to 1.0.1 , Gradle says
Copy code
Failed to resolve: org.jetbrains.kotlinx:kotlinx-serialization-runtime:1.0.1
Isn't this available on jcenter? or what should I do?
k
there was some renaming going on, here's how I use it:
Copy code
implementation("org.jetbrains.kotlinx", "kotlinx-serialization-core", "1.0.1")
implementation("org.jetbrains.kotlinx", "kotlinx-serialization-json", "1.0.1")
I think JSON part is optional, but I keep it anyway
and of course, you need a plugin, I think that remained the same
Copy code
kotlin("plugin.serialization") version "1.4.21"
r
Thanks, it seem like I can find the org.jetbrains.kotlinxkotlinx serialization core1.0.1
The id of the core artifact with
@Serializable
annotation and
Json
format was changed from
kotlinx-serialization-runtime
to
kotlinx-serialization-core
to be more clear and aligned with other kotlinx libraries.
In 1.0.0-RC2,
Json
class and related entities are located in
kotlinx-serialization-json
artifact. To migrate, simply replace
kotlinx-serialization-core
dependency with
-json
. Core library then will be included automatically as the transitive dependency.
For most use-cases, you should use new
kotlinx-serialization-json
artifact. Use
kotlinx-serialization-core
if you are writing a library that depends on kotlinx.serialization in a format-agnostic way of provides its own serial format.
r
I see that I need to use
kotlinx-serialization-json
since I otherwis cannot find imports for Json. Is there any harm to include both when not writing library?
I think, you answered the important question with the link to changelog. Do as I should, and skip the unneeded "if"s
v
My opinion is, if you don't use a class from the
core
artifact, don't declare it as dependencey. If you use a class from the
core
artifact explicitly, then also declare a dependency and don't just rely on it being present transitively.
👍 3