harness.core.StringCodecOps.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of harness-zio-json_3 Show documentation
Show all versions of harness-zio-json_3 Show documentation
Miscellaneous libraries/utilities for Scala.
The newest version!
package harness.core
import cats.data.NonEmptyList
import cats.syntax.either.*
import harness.core.*
import zio.json.*
implicit class StringEncoderOps(self: StringEncoder.type) {
def fromJsonEncoder[T: JsonEncoder]: StringEncoder[T] = JsonEncoder[T].encodeJson(_, None).toString
}
implicit class StringDecoderOps(self: StringDecoder.type) {
def fromJsonDecoder[T: JsonDecoder]: StringDecoder[T] = JsonDecoder[T].decodeJson(_).leftMap(NonEmptyList.one)
}
implicit class StringCodecOps(self: StringCodec.type) {
def fromJsonCodec[T: JsonCodec]: StringCodec[T] = StringCodec(StringEncoder.fromJsonEncoder[T], StringDecoder.fromJsonDecoder[T])
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy