Claude Code Plugins

Community-maintained marketplace

Feedback

kotlinx.serialization - JSON, Protobuf, custom serializers

Install Skill

1Download skill
2Enable skills in Claude

Open claude.ai/settings/capabilities and find the "Skills" section

3Upload to Claude

Click "Upload skill" and select the downloaded ZIP file

Note: Please verify skill by going through its instructions before using it.

SKILL.md

name kotlin-serialization
description kotlinx.serialization - JSON, Protobuf, custom serializers
version 1.0.0
sasmp_version 1.3.0
bonded_agent 01-kotlin-fundamentals
bond_type SECONDARY_BOND
execution [object Object]
parameters [object Object]
logging [object Object]

Kotlin Serialization Skill

Type-safe serialization with kotlinx.serialization.

Topics Covered

JSON Serialization

@Serializable
data class User(
    val id: Long,
    val name: String,
    @SerialName("email_address") val email: String,
    val createdAt: Instant = Instant.now()
)

val json = Json {
    ignoreUnknownKeys = true
    encodeDefaults = true
    prettyPrint = true
}

val user = json.decodeFromString<User>(jsonString)
val output = json.encodeToString(user)

Custom Serializers

object InstantSerializer : KSerializer<Instant> {
    override val descriptor = PrimitiveSerialDescriptor("Instant", PrimitiveKind.LONG)
    override fun serialize(encoder: Encoder, value: Instant) = encoder.encodeLong(value.toEpochMilli())
    override fun deserialize(decoder: Decoder) = Instant.ofEpochMilli(decoder.decodeLong())
}

@Serializable
data class Event(
    @Serializable(with = InstantSerializer::class) val timestamp: Instant
)

Polymorphic Serialization

@Serializable
sealed class Response {
    @Serializable @SerialName("success")
    data class Success(val data: String) : Response()

    @Serializable @SerialName("error")
    data class Error(val message: String) : Response()
}

val json = Json { classDiscriminator = "type" }

Troubleshooting

Issue Resolution
"Serializer not found" Add @Serializable or plugin
Unknown property fails Set ignoreUnknownKeys = true

Usage

Skill("kotlin-serialization")