commonMain.io.github.optimumcode.json.pointer.JsonPointerSerializer.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of json-schema-validator Show documentation
Show all versions of json-schema-validator Show documentation
Multiplatform Kotlin implementation of JSON schema validator
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())
}
}