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

io.taig.patch.JsonPatchEncoder.scala Maven / Gradle / Ivy

There is a newer version: 0.2.0
Show newest version
package io.taig.patch

import io.circe.Json

/** Encode a value to its `Json` representation and its field name */
trait JsonPatchEncoder[A] { self =>
  def encode(value: A): (String, Json)

  final def contramap[B](f: B => A): JsonPatchEncoder[B] = new JsonPatchEncoder[B] {
    override def encode(value: B): (String, Json) = self.encode(f(value))
  }
}

object JsonPatchEncoder {
  def apply[A](implicit encoder: JsonPatchEncoder[A]): JsonPatchEncoder[A] = encoder
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy