Conveniently construct a format for a case class
type.
Conveniently construct a format for a case class
type.
For example:
case class StorageKey(distributionKey: String, sortKey: String) object StorageKey { implicit val keyFormat: KeyFormat[StorageKey] = KeyFormat.caseClass((apply _).tupled, unapply) }
Defines a format that only adds the "id"
field to response objects.
Defines a format that only adds the "id"
field to response objects. The "id"
field
will contain the natural JSON representation for primitive type P
.
(JSON number for Int
, etc.)
Defines a KeyFormat
that only adds the "id"
field to response objects.
Defines a KeyFormat
that only adds the "id"
field to response objects. The "id"
field
will contain a string representation of the id, as specified by stringKeyFormatT
.
Note: If K
contains a single, primitive type field (like case class A(i: Int)
), you may
want to use idAsPrimitive instead. With idAsStringOnly, the output object will
be {"id": "3"}
, whereas with idAsPrimitive, it'll be {"id": 3}
.
Note: If you want to add additional fields to JSON response objects (for example, if K
is a
composite key), use idAsStringWithFields instead.
Defines a KeyFormat
that adds the "id"
field to response objects as well as others
returned by idWrites
.
Defines a KeyFormat
that adds the "id"
field to response objects as well as others
returned by idWrites
. Use this for composite id types where clients should have access
to parts of the id in addition to the whole opaque string.
See idAsStringOnly.
Augment K
's format with an additional fallback JsReads implementation.
Augment K
's format with an additional fallback JsReads implementation.
The key type.
An alternate JsValue to K
Reads implementation.
The standard KeyFormat to augment.
The augmented KeyFormat.