All Downloads are FREE. Search and download functionalities are using the official Maven repository.

commonMain.io.github.optimumcode.json.pointer.JsonPointerSerializer.kt Maven / Gradle / Ivy

There is a newer version: 0.3.0
Show newest version
package io.github.optimumcode.json.pointer

import kotlinx.serialization.KSerializer
import kotlinx.serialization.descriptors.PrimitiveKind
import kotlinx.serialization.descriptors.PrimitiveSerialDescriptor
import kotlinx.serialization.descriptors.SerialDescriptor
import kotlinx.serialization.encoding.Decoder
import kotlinx.serialization.encoding.Encoder

internal object JsonPointerSerializer : KSerializer {
  override val descriptor: SerialDescriptor =
    PrimitiveSerialDescriptor(
      "io.github.optimumcode.json.pointer.JsonPointer",
      PrimitiveKind.STRING,
    )

  override fun deserialize(decoder: Decoder): JsonPointer = JsonPointer(decoder.decodeString())

  override fun serialize(
    encoder: Encoder,
    value: JsonPointer,
  ) {
    encoder.encodeString(value.toString())
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy