kotlinx-serialization

Configure kotlinx-serialization JSON with shared instances and sealed hierarchies.

1|Updated Apr 24, 2026
One-click install
npx skills add https://github.com/dimitriRemoiville/cc-mobile --skill kotlinx-serialization
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: kotlinx-serialization
Source: https://github.com/dimitriRemoiville/cc-mobile/tree/main/plugins/cc-mobile-kmm/skills/kotlinx-serialization
Command: npx skills add https://github.com/dimitriRemoiville/cc-mobile --skill kotlinx-serialization

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Kotlin Multiplatform projects often struggle to implement consistent, robust serialization across platforms and boundaries. This Skill provides guidance on configuring JSON with a shared Json instance, managing polymorphism with sealed hierarchies, and applying custom serializers to ensure stable wire formats in Ktor, SQLDelight, and settings values.

Core Features & Use Cases

  • Centralized Json configuration for KMP with sensible defaults and safe deserialization behavior.
  • Polymorphic models using sealed hierarchies and discriminators for forward-compatible APIs.
  • Custom serializers and enum handling to align Kotlin types with wire formats and server expectations.
  • Practical use cases across Ktor bodies, SQLDelight blobs, and cross-platform data transfer.

Quick Start

Configure a shared Json instance, annotate common and platform-specific data classes with @Serializable, and start using kotlinx-serialization in your KMP modules.

Frequently Asked Questions about kotlinx-serialization

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I configure kotlinx-serialization for consistent JSON handling in Kotlin Multiplatform?

Configure kotlinx-serialization for Kotlin Multiplatform by creating a centralized shared Json instance with safe deserialization defaults. This ensures consistent JSON parsing and serialization across all platform targets.

How do I handle polymorphism with sealed class hierarchies in Kotlin Multiplatform serialization?

Handle polymorphism in Kotlin Multiplatform serialization by using sealed class hierarchies with careful discriminator configuration. This approach ensures forward-compatible APIs when serializing complex object graphs to JSON.

Can I use kotlinx-serialization with Ktor and SQLDelight in a KMP project?

Yes, kotlinx-serialization works with Ktor and SQLDelight in Kotlin Multiplatform projects. It applies custom serializers to manage stable wire formats for Ktor network bodies and SQLDelight blob storage.

What is the best way to align Kotlin types with custom JSON wire formats?

The best way to align Kotlin types with custom JSON wire formats is by applying custom serializers and specific enum handling. This ensures your data classes match server expectations during serialization.

Why do I need @Serializable annotations for Kotlin Multiplatform data transfer?

You need @Serializable annotations for Kotlin Multiplatform data transfer because they mark common and platform-specific data classes for the compiler plugin. This requirement enables stable cross-platform serialization and safe data exchange.

What are the limitations of kotlinx-serialization for forward compatibility in KMP?

Limitations regarding forward compatibility in KMP require careful discriminator usage within sealed hierarchies. Failing to configure a shared Json instance properly can lead to deserialization failures when APIs evolve.