[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-7241":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":7,"languages":10,"totalLinesOfCode":10,"stars":11,"forks":12,"watchers":13,"openIssues":14,"contributorsCount":15,"subscribersCount":15,"size":15,"stars1d":15,"stars7d":16,"stars30d":17,"stars90d":15,"forks30d":15,"starsTrendScore":18,"compositeScore":19,"rankGlobal":10,"rankLanguage":10,"license":20,"archived":21,"fork":21,"defaultBranch":22,"hasWiki":21,"hasPages":23,"topics":24,"createdAt":10,"pushedAt":10,"updatedAt":30,"readmeContent":31,"aiSummary":32,"trendingCount":15,"starSnapshotCount":15,"syncStatus":16,"lastSyncTime":33,"discoverSource":34},7241,"kotlinx.serialization","Kotlin\u002Fkotlinx.serialization","Kotlin","Kotlin multiplatform \u002F multi-format serialization ","",null,5919,676,99,287,0,2,15,1,39.49,"Apache License 2.0",false,"master",true,[25,26,27,28,29],"cbor","json","kotlin","protobuf","serialization","2026-06-12 02:01:36","# Kotlin multiplatform \u002F multi-format reflectionless serialization\n\n[![Kotlin Stable](https:\u002F\u002Fkotl.in\u002Fbadges\u002Fstable.svg)](https:\u002F\u002Fkotlinlang.org\u002Fdocs\u002Fcomponents-stability.html)\n[![JetBrains official project](https:\u002F\u002Fjb.gg\u002Fbadges\u002Fofficial.svg)](https:\u002F\u002Fconfluence.jetbrains.com\u002Fdisplay\u002FALL\u002FJetBrains+on+GitHub)\n[![GitHub license](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Flicense-Apache%20License%202.0-blue.svg?style=flat)](http:\u002F\u002Fwww.apache.org\u002Flicenses\u002FLICENSE-2.0)\n[![TeamCity build](https:\u002F\u002Fimg.shields.io\u002Fteamcity\u002Fhttp\u002Fteamcity.jetbrains.com\u002Fs\u002FKotlinTools_KotlinxSerialization_Ko.svg)](https:\u002F\u002Fteamcity.jetbrains.com\u002FviewType.html?buildTypeId=KotlinTools_KotlinxSerialization_Ko&guest=1)\n[![Kotlin](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fkotlin-2.3.20-blue.svg?logo=kotlin)](http:\u002F\u002Fkotlinlang.org)\n[![Maven Central](https:\u002F\u002Fimg.shields.io\u002Fmaven-central\u002Fv\u002Forg.jetbrains.kotlinx\u002Fkotlinx-serialization-core\u002F1.11.0)](https:\u002F\u002Fcentral.sonatype.com\u002Fartifact\u002Forg.jetbrains.kotlinx\u002Fkotlinx-serialization-core\u002F1.11.0)\n[![KDoc link](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002FAPI_reference-KDoc-blue)](https:\u002F\u002Fkotlinlang.org\u002Fapi\u002Fkotlinx.serialization\u002F)\n[![Slack channel](https:\u002F\u002Fimg.shields.io\u002Fbadge\u002Fchat-slack-blue.svg?logo=slack)](https:\u002F\u002Fkotlinlang.slack.com\u002Fmessages\u002Fserialization\u002F)\n\nKotlin serialization consists of a compiler plugin, that generates visitor code for serializable classes,\n runtime library with core serialization API and support libraries with various serialization formats.\n\n* Supports Kotlin classes marked as `@Serializable` and standard collections.\n* Provides [JSON](formats\u002FREADME.md#JSON), [Protobuf](formats\u002FREADME.md#ProtoBuf), [CBOR](formats\u002FREADME.md#CBOR), [Hocon](formats\u002FREADME.md#HOCON) and [Properties](formats\u002FREADME.md#properties) formats.\n* Complete multiplatform support: JVM, JS and Native.\n\n## Table of contents\n\n\u003C!--- TOC -->\n\n* [Introduction and references](#introduction-and-references)\n* [Setup](#setup)\n  * [Gradle](#gradle)\n    * [1) Setting up the serialization plugin](#1-setting-up-the-serialization-plugin)\n    * [2) Dependency on the JSON library](#2-dependency-on-the-json-library)\n  * [Android](#android)\n  * [Multiplatform (Common, JS, Native)](#multiplatform-common-js-native)\n  * [Maven](#maven)\n  * [Bazel](#bazel)\n\n\u003C!--- END -->\n\n* **Additional links**\n  * [Kotlin Serialization Guide](docs\u002Fserialization-guide.md)\n  * [Full API reference](https:\u002F\u002Fkotlinlang.org\u002Fapi\u002Fkotlinx.serialization\u002F)\n  * [Submitting issues and PRs](CONTRIBUTING.md)\n  * [Building this library](docs\u002Fbuilding.md)\n\n## Introduction and references\n\nHere is a small example.\n\n```kotlin\nimport kotlinx.serialization.*\nimport kotlinx.serialization.json.*\n\n@Serializable \ndata class Project(val name: String, val language: String)\n\nfun main() {\n    \u002F\u002F Serializing objects\n    val data = Project(\"kotlinx.serialization\", \"Kotlin\")\n    val string = Json.encodeToString(data)  \n    println(string) \u002F\u002F {\"name\":\"kotlinx.serialization\",\"language\":\"Kotlin\"} \n    \u002F\u002F Deserializing back into objects\n    val obj = Json.decodeFromString\u003CProject>(string)\n    println(obj) \u002F\u002F Project(name=kotlinx.serialization, language=Kotlin)\n}\n``` \n\n> You can get the full code [here](guide\u002Fexample\u002Fexample-readme-01.kt).\n\n\u003C!--- TEST_NAME ReadmeTest -->\n\n\u003C!--- TEST \n{\"name\":\"kotlinx.serialization\",\"language\":\"Kotlin\"}\nProject(name=kotlinx.serialization, language=Kotlin)\n-->\n\n**Read the [Kotlin Serialization Guide](docs\u002Fserialization-guide.md) for all details.**\n\nYou can find auto-generated documentation website on [kotlinlang.org](https:\u002F\u002Fkotlinlang.org\u002Fapi\u002Fkotlinx.serialization\u002F).\n\n## Setup\n\n[New versions](https:\u002F\u002Fplugins.gradle.org\u002Fplugin\u002Forg.jetbrains.kotlin.plugin.serialization) of the serialization plugin are released in tandem with each new Kotlin compiler version.\n\nMake sure you have the corresponding Kotlin plugin installed in the IDE, no additional plugins for IDE are required.\n\n### Gradle\n\nTo set up kotlinx.serialization, you have to do two things:\n1) Add the **[serialization plugin](#1-setting-up-the-serialization-plugin)**.\n2) Add the **[serialization library dependency](#2-dependency-on-the-json-library)**.\n\n#### 1) Setting up the serialization plugin\n\nYou can set up the serialization plugin with the Kotlin plugin using the\n[Gradle plugins DSL](https:\u002F\u002Fdocs.gradle.org\u002Fcurrent\u002Fuserguide\u002Fplugins.html#sec:plugins_block):\n\nKotlin DSL:\n\n```kotlin\nplugins {\n    kotlin(\"jvm\") version \"2.3.20\" \u002F\u002F or kotlin(\"multiplatform\") or any other kotlin plugin\n    kotlin(\"plugin.serialization\") version \"2.3.20\"\n}\n```       \n\nGroovy DSL:\n\n```gradle\nplugins {\n    id 'org.jetbrains.kotlin.multiplatform' version '2.3.20'\n    id 'org.jetbrains.kotlin.plugin.serialization' version '2.3.20'\n}\n```\n\n> Kotlin versions before 1.4.0 are not supported by the stable release of Kotlin serialization.\n\n\u003Cdetails>\n  \u003Csummary>Using \u003Ccode>apply plugin\u003C\u002Fcode> (the old way)\u003C\u002Fsummary>\n\nFirst, you have to add the serialization plugin to your classpath as the other [compiler plugins](https:\u002F\u002Fkotlinlang.org\u002Fdocs\u002Freference\u002Fcompiler-plugins.html):\n\nKotlin DSL:\n\n```kotlin\nbuildscript {\n    repositories { mavenCentral() }\n\n    dependencies {\n        val kotlinVersion = \"2.3.20\"\n        classpath(kotlin(\"gradle-plugin\", version = kotlinVersion))\n        classpath(kotlin(\"serialization\", version = kotlinVersion))\n    }\n}\n```\n\nGroovy DSL:\n\n```gradle\nbuildscript {\n    ext.kotlin_version = '2.3.20'\n    repositories { mavenCentral() }\n\n    dependencies {\n        classpath \"org.jetbrains.kotlin:kotlin-serialization:$kotlin_version\"\n    }\n}\n```\n\nThen you can `apply plugin` (example in Groovy):\n\n```gradle\napply plugin: 'kotlin' \u002F\u002F or 'kotlin-multiplatform' for multiplatform projects\napply plugin: 'kotlinx-serialization'\n```\n\u003C\u002Fdetails>\n\n#### 2) Dependency on the JSON library\n\nAfter setting up the plugin, you have to add a dependency on the serialization library.\nNote that while the plugin has version the same as the compiler one, runtime library has different coordinates, repository and versioning.\n\nKotlin DSL:\n\n```kotlin\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    implementation(\"org.jetbrains.kotlinx:kotlinx-serialization-json:1.11.0\")\n}\n```\n\nGroovy DSL:\n\n```gradle\nrepositories {\n    mavenCentral()\n}\n\ndependencies {\n    implementation \"org.jetbrains.kotlinx:kotlinx-serialization-json:1.11.0\"\n}\n```\n\n>We also provide `kotlinx-serialization-core` artifact that contains all serialization API but does not have a bundled serialization format with it\n\n### Android\n\nBy default, proguard rules are supplied with the library.\n[These rules](rules\u002Fcommon.pro) keep serializers for _all_ serializable classes that are retained after shrinking,\nso you don't need additional setup.\n\n**However, these rules do not affect serializable classes if they have named companion objects.**\n\nIf you want to serialize classes with named companion objects, you need to add and edit rules below to your `proguard-rules.pro` configuration. \n\nNote that the rules for R8 differ depending on the [compatibility mode](https:\u002F\u002Fr8.googlesource.com\u002Fr8\u002F+\u002Frefs\u002Fheads\u002Fmaster\u002Fcompatibility-faq.md) used.\n\n\u003Cdetails>\n\u003Csummary>Example of named companion rules for ProGuard and R8 compatibility mode\u003C\u002Fsummary>\n\n```proguard\n# Serializer for classes with named companion objects are retrieved using `getDeclaredClasses`.\n# If you have any, replace classes with those containing named companion objects.\n-keepattributes InnerClasses # Needed for `getDeclaredClasses`.\n\n-if @kotlinx.serialization.Serializable class\ncom.example.myapplication.HasNamedCompanion, # \u003C-- List serializable classes with named companions.\ncom.example.myapplication.HasNamedCompanion2\n{\n    static **$* *;\n}\n-keepnames class \u003C1>$$serializer { # -keepnames suffices; class is kept when serializer() is kept.\n    static \u003C1>$$serializer INSTANCE;\n}\n```\n\u003C\u002Fdetails>\n\n\n\u003Cdetails>\n\u003Csummary>Example of named companion rules for R8 full mode\u003C\u002Fsummary>\n\n```proguard\n# Serializer for classes with named companion objects are retrieved using `getDeclaredClasses`.\n# If you have any, replace classes with those containing named companion objects.\n-keepattributes InnerClasses # Needed for `getDeclaredClasses`.\n\n-if @kotlinx.serialization.Serializable class\ncom.example.myapplication.HasNamedCompanion, # \u003C-- List serializable classes with named companions.\ncom.example.myapplication.HasNamedCompanion2\n{\n    static **$* *;\n}\n-keepnames class \u003C1>$$serializer { # -keepnames suffices; class is kept when serializer() is kept.\n    static \u003C1>$$serializer INSTANCE;\n}\n\n# Keep both serializer and serializable classes to save the attribute InnerClasses\n-keepclasseswithmembers, allowshrinking, allowobfuscation, allowaccessmodification class\ncom.example.myapplication.HasNamedCompanion, # \u003C-- List serializable classes with named companions.\ncom.example.myapplication.HasNamedCompanion2\n{\n    *;\n}\n```\n\u003C\u002Fdetails>\n\nIn case you want to exclude serializable classes that are used, but never serialized at runtime,\nyou will need to write custom rules with narrower [class specifications](https:\u002F\u002Fwww.guardsquare.com\u002Fmanual\u002Fconfiguration\u002Fusage).\n\n### Multiplatform (Common, JS, Native)\n\nMost of the modules are also available for Kotlin\u002FJS and Kotlin\u002FNative.\nYou can add dependency to the required module right to the common source set:\n```gradle\ncommonMain {\n    dependencies {\n        \u002F\u002F Works as common dependency as well as the platform one\n        implementation \"org.jetbrains.kotlinx:kotlinx-serialization-json:$serialization_version\"\n    }\n}\n```\nThe same artifact coordinates can be used to depend on platform-specific artifact in platform-specific source-set.\n\n### Maven\n\nEnsure the proper version of Kotlin and serialization version:\n\n```xml\n\u003Cproperties>\n    \u003Ckotlin.version>2.3.20\u003C\u002Fkotlin.version>\n    \u003Cserialization.version>1.11.0\u003C\u002Fserialization.version>\n\u003C\u002Fproperties>\n```\n\nAdd serialization plugin to Kotlin compiler plugin:\n\n```xml\n\u003Cbuild>\n    \u003Cplugins>\n        \u003Cplugin>\n            \u003CgroupId>org.jetbrains.kotlin\u003C\u002FgroupId>\n            \u003CartifactId>kotlin-maven-plugin\u003C\u002FartifactId>\n            \u003Cversion>${kotlin.version}\u003C\u002Fversion>\n            \u003Cexecutions>\n                \u003Cexecution>\n                    \u003Cid>compile\u003C\u002Fid>\n                    \u003Cphase>compile\u003C\u002Fphase>\n                    \u003Cgoals>\n                        \u003Cgoal>compile\u003C\u002Fgoal>\n                    \u003C\u002Fgoals>\n                \u003C\u002Fexecution>\n            \u003C\u002Fexecutions>\n            \u003Cconfiguration>\n                \u003CcompilerPlugins>\n                    \u003Cplugin>kotlinx-serialization\u003C\u002Fplugin>\n                \u003C\u002FcompilerPlugins>\n            \u003C\u002Fconfiguration>\n            \u003Cdependencies>\n                \u003Cdependency>\n                    \u003CgroupId>org.jetbrains.kotlin\u003C\u002FgroupId>\n                    \u003CartifactId>kotlin-maven-serialization\u003C\u002FartifactId>\n                    \u003Cversion>${kotlin.version}\u003C\u002Fversion>\n                \u003C\u002Fdependency>\n            \u003C\u002Fdependencies>\n        \u003C\u002Fplugin>\n    \u003C\u002Fplugins>\n\u003C\u002Fbuild>\n```\n\nAdd dependency on serialization runtime library:\n\n```xml\n\u003Cdependency>\n    \u003CgroupId>org.jetbrains.kotlinx\u003C\u002FgroupId>\n    \u003CartifactId>kotlinx-serialization-json\u003C\u002FartifactId>\n    \u003Cversion>${serialization.version}\u003C\u002Fversion>\n\u003C\u002Fdependency>\n```\n\n### Bazel\n\nTo setup the Kotlin compiler plugin for Bazel, follow [the\nexample](https:\u002F\u002Fgithub.com\u002Fbazelbuild\u002Frules_kotlin\u002Ftree\u002Fmaster\u002Fexamples\u002Fplugin\u002Fsrc\u002Fserialization)\nfrom the `rules_kotlin` repository.\n","Kotlinx.serialization 是一个用于 Kotlin 跨平台和多格式序列化的库。它支持标记为 `@Serializable` 的 Kotlin 类及标准集合，并提供 JSON、Protobuf、CBOR、Hocon 和 Properties 等多种数据格式的序列化与反序列化功能。该库由编译器插件生成访问代码和运行时库组成，具备完整的跨平台支持（包括 JVM、JS 和 Native），适用于需要在不同平台间高效传输结构化数据的应用场景。","2026-06-11 03:11:21","top_language"]