Fully automatic generation of play-json
serializers
libraryDependencies += "ru.makkarpov" %% "pray-json" % VERSION
Features (see tests):
- fully recursive generation — no need for intermediate serializer implicits;
- generation can be restricted using
@requireImplicit
annotation. - implicit search for
Format[T]
happens also in a companion object ofT
, and, if companion itself is inside of object — in all outer objects. - recursive structures are also supported.
- generation can be restricted using
- generation of
case class
serializers:- simple case classes;
- renamed fields using
@key
annotation. it also can transform key names to snake_case automatically; - support for default values;
- support for
Option
al fields. - in some APIs fields should be serialized as strings even if they aren't strings. This is also supported;
- inline formatting of case classes with single parameter
- generation of
sealed
serializers:- automatically added
type
field to distinguish between cases; - name and value of
type
field can be customized with annotations; - support for fallback cases;
- automatically added
- generation of serializers for collections:
Traversable
s:Seq
s,Set
s, ...;Map
s: custom key types are supported viaKeyFormat[K]
;Option
s (when not inside of a case class) are serialized either as[]
or[something]
.
- Enumerations:
Value
s are serialized as strings with their name;ValueSet
s are serialized as array of strings.