Can be used on case class fields and classes in sealed hierarchy to instruct automatically derived GenCodec
to use particular name instead of just using parameter or class name.
If some case class field has default value, you can use this annotation on this field to instruct an
automatically derived GenCodec
to not persist the value of that field if it's equal to the default value.
If some case class field has default value, you can use this annotation on this field to instruct an
automatically derived GenCodec
to not persist the value of that field if it's equal to the default value.
For example:
case class Something(str: String, @transientDefault int: Int = 42) object Something { implicit val codec = GenCodec.auto[Something] }
GenCodec.write(someOutput, Something("lol", 10))
would yield object {"str": "lol", "int": 10}
but
GenCodec.write(someOutput, Something("lol", 42))
would yield object {"str": "lol"}
because the value of int
is the same as the default value.
Can be used on case classes with exactly one field to instruct automatically generated GenCodec
that the
class is a "transparent wrapper" and should be serialized to the same representation as the value of its sole
field.
Can be used on case class fields and classes in sealed hierarchy to instruct automatically derived
GenCodec
to use particular name instead of just using parameter or class name.For example:
GenCodec.write(someOutput, Something(42))
would write an object{"dbname": 42}
instead of{"paramname": 42}
.