Skip to content

Conversation

@daniCsorbaJB
Copy link

This is the second part of the Kotlin Serialization rewrite.

Related YouTract ticket is: KT-80054 [Docs][Libraries] Get started with Kotlin Serialization)

@daniCsorbaJB daniCsorbaJB changed the title feat: adding the get started page Documentation rewrite - Get started page Aug 11, 2025
Copy link
Member

@sandwwraith sandwwraith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

.

Copy link
Member

@sandwwraith sandwwraith left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've realized we have a tip

We also provide kotlinx-serialization-core artifact that contains all serialization API but does not have a bundled serialization format with it

in our current README.md, which is missing from this document.
Perhaps it is better to place it in the serialization.md/Kotlin serialization libraries or Supported serialization formats section in the form of

Pro tip: if you do not want a dependency on a particular format (e.g., you are writing your own serialization format), you can use kotlinx-serialization-core library.

@daniCsorbaJB
Copy link
Author

I've realized we have a tip

We also provide kotlinx-serialization-core artifact that contains all serialization API but does not have a bundled serialization format with it

in our current README.md, which is missing from this document. Perhaps it is better to place it in the serialization.md/Kotlin serialization libraries or Supported serialization formats section in the form of

Pro tip: if you do not want a dependency on a particular format (e.g., you are writing your own serialization format), you can use kotlinx-serialization-core library.

I really like the second option — let's go with that (let's put it in the supported serialization formats page)

@sandwwraith
Copy link
Member

I really like the second option — let's go with that (let's put it in the supported serialization formats page)

So, do you plan to address it?

Copy link

@sarahhaggarty sarahhaggarty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's looking nice! I have a few suggestions and questions for you.

@@ -0,0 +1,281 @@
[//]: # (title: Get started with Kotlin serialization)

[Serialization](serialization.md) converts objects into a format that can be stored or transmitted and later reconstructed.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
[Serialization](serialization.md) converts objects into a format that can be stored or transmitted and later reconstructed.
[Serialization](serialization.md) converts objects into a format you can store or transmit and later reconstruct.

What do you think about making this more active?

[Serialization](serialization.md) converts objects into a format that can be stored or transmitted and later reconstructed.

Kotlin serialization supports multiple formats.
This tutorial shows you how to add the necessary plugins and dependencies for Kotlin serialization and how to serialize and deserialize objects in JSON format.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
This tutorial shows you how to add the necessary plugins and dependencies for Kotlin serialization and how to serialize and deserialize objects in JSON format.
This tutorial shows you how to add the necessary plugins and dependencies for Kotlin serialization, and how to serialize and deserialize objects in JSON format.

Kotlin serialization supports multiple formats.
This tutorial shows you how to add the necessary plugins and dependencies for Kotlin serialization and how to serialize and deserialize objects in JSON format.

## Add plugins and dependencies for Kotlin serialization to your project

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
## Add plugins and dependencies for Kotlin serialization to your project
## Add plugins and dependencies

I think we can shorten this since it's clear we're talking about the Kotlin serialization library.

>
{style="tip"}

### Add the Kotlin serialization library to a multiplatform project

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
### Add the Kotlin serialization library to a multiplatform project
### Add the library to a multiplatform project

### Configure R8 for Kotlin serialization in Android projects {initial-collapse-state="collapsed" collapsible="true"}

The Kotlin serialization library includes default [ProGuard rules](https://github.com/Kotlin/kotlinx.serialization/blob/master/rules/common.pro), so you don't need additional setup to keep serializers for all serializable classes after shrinking.
These rules don't apply to classes with named companion objects.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
These rules don't apply to classes with named companion objects.
However, these rules don't apply to classes with named companion objects.


To make a class serializable, you need to mark it with the [`@Serializable`](https://kotlinlang.org/api/kotlinx.serialization/kotlinx-serialization-core/kotlinx.serialization/-serializable/) annotation.
This annotation instructs the compiler to generate the code required for serializing and deserializing instances of the class.
For more information, see [The @Serialization annotation](serialization-customization-options.md#the-serializable-annotation).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
For more information, see [The @Serialization annotation](serialization-customization-options.md#the-serializable-annotation).
For more information, see [The `@Serialization` annotation](serialization-customization-options.md#the-serializable-annotation).


```kotlin
@Serializable
data class Data(val a: Int, val b: String)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you improve the example by making it more real world like? For example, the data class could be called Book and have title which is a String and yearPublished as an Int.

```
{kotlin-runnable="true"}

Congratulations! You have successfully serialized an object to JSON and deserialized it back into an object in Kotlin!

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Congratulations! You have successfully serialized an object to JSON and deserialized it back into an object in Kotlin!
Congratulations! You have successfully serialized an object to JSON and deserialized it back into an object in Kotlin.

Nitpick. Just to make it sound not so excitable :)


## What's next
* Learn how to serialize standard types, including built-in types like numbers and strings, in [Serialize built-in types](serialization-serialize-builtin-types.md).

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By "standard" do you mean basic types?

## What's next
* Learn how to serialize standard types, including built-in types like numbers and strings, in [Serialize built-in types](serialization-serialize-builtin-types.md).
* Discover how to customize class serialization and adjust the default behavior of the `@Serializable` annotation in the [Serialize classes](serialization-customization-options.md) section.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will it be a section in this page? Or is it a page itself?

// {"a":42,"b":"str"}
}
```
{kotlin-runnable="true"}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you give it an ID so we can see how many people run it in GA?

// Data(a=42, b=str)
}
```
{kotlin-runnable="true"}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would also be great to have an ID here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants