Product types are disambiguated by a {"key":"value",...}.
Product types are disambiguated by a {"key":"value",...}. Of
course, this will fail if the product type has a field with the
same name as the key. The default key is the word "type" which
is a keyword in Scala so unlikely to collide with too many case
classes.
This variant is most common in JSON serialisation schemes and well supported by other frameworks.
Sometimes the wire format needs to match an existing format and
JsNull behaviour needs to be customised.
Sometimes the wire format needs to match an existing format and
JsNull behaviour needs to be customised. This allows null
behaviour to be defined at the product level. Field level control
is only possible with a user-defined RootJsonFormat.
Product types are disambiguated by an extra JSON map layer containing a single key which is the name of the type of product contained in the value.
Product types are disambiguated by an extra JSON map layer
containing a single key which is the name of the type of product
contained in the value. e.g. {"MyType":{...}}
This variant may be more appropriate for non-polymorphic schemas such as MongoDB and Mongoose (consider using the above format on your endpoints, and this format when persisting).
a JsonFormat[HList] or JsonFormat[Coproduct] would not retain the
type information for the full generic that it is serialising.
a JsonFormat[HList] or JsonFormat[Coproduct] would not retain the
type information for the full generic that it is serialising.
This allows us to pass the wrapped type, achieving: 1) custom
CoproductHints on a per-trait level 2) configurable null behaviour
on a per product level 3) clearer error messages.
This is intentionally not part of the JsonFormat hierarchy to
avoid ambiguous implicit errors.
All values serialising to JsNull will be included in the wire format.
All values serialising to JsNull will be included in the wire format. Ambiguous.
Option values of None are omitted, but Some values of JsNull are retained.
Option values of None are omitted, but Some values of JsNull are retained. Default.
No values serialising to JsNull will be included in the wire format.
No values serialising to JsNull will be included in the wire format. Ambiguous.
Format for LabelledGenerics that uses the HList or Coproduct
marshaller above.
Format for LabelledGenerics that uses the HList or Coproduct
marshaller above.
Blah.Aux[T, Repr] is a trick to work around scala compiler
constraints. We'd really like to have only one type parameter
(T) implicit list g: LabelledGeneric[T], f:
Cached[Strict[JsonFormat[T.Repr]]] but that's not possible.