Derives an OWrites[A]
Derives a Reads[A]
Adapter function to transform case classes member names during the derivation process
Adapter function to transform case classes member names during the derivation process
A NameAdapter can be used to customize the derivation process, allowing to apply a transformation function to case classes member names when deriving serializers/deserializers
For instance, it can be used to derive serializers/deserializers that use a different casing for the json keys.
For example, to derive a Format[A] that uses snake_case for the json keys (using the predefined NameAdapter.snakeCase)
import julienrf.json.derived import julienrf.json.derived.NameAdapter import play.api.libs.json.{Format, Json} case class Bar(camelCase: String) object Bar { implicit val format: Format[Bar] = derived.oformat[Bar](NameAdapter.snakeCase) }
scala> Json.toJson(Bar("a json value")) res0: play.api.libs.json.JsValue = {"camel_case":"a json value"} scala> Json.fromJson[Bar](Json.parse("""{"camel_case":"a json value"}""")) res1: play.api.libs.json.JsResult[Bar] = JsSuccess(Bar(a json value),)
Strategy to serialize a tagged type (used to discriminate sum types).
Strategy to serialize a tagged type (used to discriminate sum types).
Built-in instances live in the companion object.
Strategy to deserialize a tagged type (used to discriminate sum types).
Strategy to deserialize a tagged type (used to discriminate sum types).
Built-in instances live in the companion object.