Package

ru.makkarpov.extjson

annotations

Permalink

package annotations

Visibility
  1. Public
  2. All

Type Members

  1. case class addSubclass[T]() extends Product with Serializable

    Permalink

    Workaround to https://issues.scala-lang.org/browse/SI-7046 If compiler fails to detect subclasses automatically, user can specify it manually using this annotation

    Workaround to https://issues.scala-lang.org/browse/SI-7046 If compiler fails to detect subclasses automatically, user can specify it manually using this annotation

    T

    Class

  2. case class fallbackCase() extends Annotation with StaticAnnotation with Product with Serializable

    Permalink

    Subclass annotated with this annotation will be selected if none of classes match provided type.

  3. case class formatInline() extends Annotation with StaticAnnotation with Product with Serializable

    Permalink

    On case classes with single field it forces serializer to write this field directly to JSON, omitting object wrapper.

    On case classes with single field it forces serializer to write this field directly to JSON, omitting object wrapper. On sealed classes/traits it forces serializer to omit type tags.

  4. case class key(key: String) extends Annotation with StaticAnnotation with Product with Serializable

    Permalink

    Specifies a key to use in case classes instead of field name

    Specifies a key to use in case classes instead of field name

      case class A(@key("field") a: String)
      implicit val aFormat = Json.generate[A]
    
      Json.toJson(A("123")).toString == "{\"field\":\"123\"}"
    

    key

    JSON key

  5. case class plainOption() extends Annotation with StaticAnnotation with Product with Serializable

    Permalink

    Without @plainOption annotation Option fields are treated just like they are supposed to be - an optional fields that can be either present in object or not.

    Without @plainOption annotation Option fields are treated just like they are supposed to be - an optional fields that can be either present in object or not. Using this annotation you can switch to a fallback behavior - serialize Options either as [] or [value]

  6. case class requireImplicit() extends Annotation with StaticAnnotation with Product with Serializable

    Permalink

    Json macros will refuse to generate formatter for types with this annotations, with only exception: if you explicitly ask it to do so, e.g.:

    Json macros will refuse to generate formatter for types with this annotations, with only exception: if you explicitly ask it to do so, e.g.:

      @requireImplicit
      case class Something(field1: String, ...)
    
      implicit val somethingFormat = Json.generate[Something] // works
    

    It is useful to make sure that recursive generation will not go too deep and will use existing implicits.

  7. case class serializeDefaults() extends Annotation with StaticAnnotation with Product with Serializable

    Permalink

    By default serializer omits fields that are equal to their default values.

    By default serializer omits fields that are equal to their default values. Using this annotation you can ask it to emit them.

    This annotation can be applied either to whole class or per field.

  8. case class typeField(field: String) extends Annotation with StaticAnnotation with Product with Serializable

    Permalink
  9. case class typeValue(value: String) extends Annotation with StaticAnnotation with Product with Serializable

    Permalink

Ungrouped