json-serialization

Defines kotlinx.serialization conventions for JSON seed data and DTOs in Kotlin projects.

Updated May 9, 2026
One-click install
npx skills add https://github.com/Bumh3rr/solvyx-app --skill json-serialization-bumh3rr
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: json-serialization
Source: https://github.com/Bumh3rr/solvyx-app/tree/main/.opencode/skill/json-serialization
Command: npx skills add https://github.com/Bumh3rr/solvyx-app --skill json-serialization-bumh3rr

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires kotlinx-serialization-json.

What problem does it solve? Kotlin teams often configure JSON serialization inconsistently, leading to fragile seed loading, enum mapping bugs, and runtime decoding exceptions. This Skill standardizes kotlinx.serialization usage across seed assets, DTOs, and API models. ## Core Features & Use Cases - Shared Json Configuration: Enforces a single configured Json instance with ignoreUnknownKeys, explicitNulls, and coerceInputValues settings. - Seed File Versioning: Provides a versioned seed file format with _version and _created_at metadata for asset-based data loading. - Polymorphic Serialization: Covers sealed classes with @SerialName discriminators for heterogeneous content lists. - Use Case: When adding a new exercise seed JSON to Android assets, apply these conventions to define the @Serializable data class, decode it from assets on Dispatchers.IO, and verify it with a roundtrip unit test. ## Quick Start Apply the JSON serialization conventions to create a serializable seed data class and load it from Android assets using the shared Json instance.

Frequently Asked Questions about json-serialization

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

FAQPage Schema
How do I configure kotlinx.serialization in a Kotlin project?▼

Add the kotlin serialization plugin and the kotlinx-serialization-json dependency to your Gradle build, then create one shared Json instance with ignoreUnknownKeys, explicitNulls set to false, and coerceInputValues enabled. Reuse that instance everywhere instead of creating local ones.

How to serialize enums with kotlinx.serialization?▼

Enums serialize as their name string by default. For custom string values, write mapper functions converting between the enum and its string representation, or use @SerialName annotations. Avoid ordinal-based serialization since reordering breaks stored data.

Can kotlinx.serialization handle polymorphic lists?▼

Yes, use a sealed class with @Serializable subclasses, each annotated with a distinct @SerialName discriminator. The Json decoder uses the type field to instantiate the correct subclass when decoding heterogeneous lists.

Why does MissingFieldException happen during JSON decoding?▼

MissingFieldException occurs when a required constructor field has no default value and is absent from the JSON. Fix it by adding a default value or making the field nullable with = null.

Should I use Gson or Moshi together with kotlinx.serialization?▼

No, mixing kotlinx.serialization with Gson or Moshi is an anti-pattern because the libraries are incompatible in annotation and configuration models. Pick kotlinx.serialization and use it consistently across the project.