makkarpov / pray-json

play-json as it was supposed to be — fully automatic generation of serializers

Version Matrix

pray-json Build Status Latest version

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 of T, and, if companion itself is inside of object — in all outer objects.
    • recursive structures are also supported.
  • 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 Optional 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;
  • generation of serializers for collections:
    • Traversables: Seqs, Sets, ...;
    • Maps: custom key types are supported via KeyFormat[K];
    • Options (when not inside of a case class) are serialized either as [] or [something].
  • Enumerations:
    • Values are serialized as strings with their name;
    • ValueSets are serialized as array of strings.