or run

npx @tessl/cli init
Log in

Version

Tile

Overview

Evals

Files

docs

configuration.mdformatting.mdinclusion-exclusion.mdindex.mdobject-creation.mdobject-identity.mdobject-structure.mdpolymorphic-types.mdproperty-control.md
tile.json

tessl/maven-com-fasterxml-jackson-core--jackson-annotations

Core annotations used for value types, used by Jackson data binding package.

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
mavenpkg:maven/com.fasterxml.jackson.core/jackson-annotations@2.19.x

To install, run

npx @tessl/cli install tessl/maven-com-fasterxml-jackson-core--jackson-annotations@2.19.0

index.mddocs/

Jackson Annotations

Jackson Annotations is a zero-dependency library providing core annotations for Jackson data binding. It enables developers to control JSON serialization and deserialization behavior through annotations, supporting property renaming, type information handling, object creation patterns, and fine-grained control over the serialization process.

Package Information

  • Package Name: jackson-annotations
  • Package Type: maven
  • Language: Java
  • Installation:
    <dependency>
      <groupId>com.fasterxml.jackson.core</groupId>
      <artifactId>jackson-annotations</artifactId>
      <version>2.19.0</version>
    </dependency>

Core Imports

import com.fasterxml.jackson.annotation.*;

Specific imports:

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonTypeInfo;

Basic Usage

import com.fasterxml.jackson.annotation.*;

public class Person {
    @JsonProperty("firstName")
    private String name;
    
    @JsonIgnore
    private String password;
    
    @JsonProperty(required = true)
    private int age;
    
    @JsonCreator
    public Person(@JsonProperty("firstName") String name, 
                  @JsonProperty("age") int age) {
        this.name = name;
        this.age = age;
    }
    
    // getters and setters
}

Architecture

Jackson Annotations follows a declarative annotation-based approach with several key components:

  • Property Annotations: Control individual property serialization (@JsonProperty, @JsonIgnore, @JsonAlias)
  • Structure Annotations: Modify object structure (@JsonUnwrapped, @JsonValue, @JsonRawValue)
  • Type System: Handle polymorphic types (@JsonTypeInfo, @JsonSubTypes, @JsonTypeName)
  • Object Creation: Control deserialization (@JsonCreator, @JacksonInject)
  • Meta-Annotations: Framework integration (@JacksonAnnotation, @JacksonAnnotationsInside)
  • Value Classes: Programmatic configuration via JacksonAnnotationValue implementations

Capabilities

Property Control

Annotations for controlling basic property serialization, naming, and access patterns. Essential for mapping Java field names to JSON properties and controlling visibility.

@JsonProperty(String value = JsonProperty.USE_DEFAULT_NAME,
              String namespace = "",
              boolean required = false,
              OptBoolean isRequired = OptBoolean.DEFAULT, 
              int index = JsonProperty.INDEX_UNKNOWN, 
              String defaultValue = "", 
              JsonProperty.Access access = JsonProperty.Access.AUTO)
public @interface JsonProperty {
    enum Access { AUTO, READ_ONLY, WRITE_ONLY, READ_WRITE }
    
    String USE_DEFAULT_NAME = "";
    int INDEX_UNKNOWN = -1;
}

@JsonAlias(String[] value = {})
public @interface JsonAlias;

@JsonGetter(String value = "")
public @interface JsonGetter;

@JsonSetter(String value = "", Nulls nulls = Nulls.DEFAULT, 
            Nulls contentNulls = Nulls.DEFAULT)
public @interface JsonSetter;

@JsonPropertyDescription(String value = "")
public @interface JsonPropertyDescription;

Property Control

Inclusion and Exclusion

Control which properties are included or excluded during serialization and deserialization, with support for conditional inclusion and unknown property handling.

@JsonIgnore(boolean value = true)
public @interface JsonIgnore;

@JsonIgnoreProperties(String[] value = {}, boolean ignoreUnknown = false,
                      boolean allowGetters = false, boolean allowSetters = false)
public @interface JsonIgnoreProperties;

@JsonInclude(JsonInclude.Include value = JsonInclude.Include.ALWAYS,
             JsonInclude.Include content = JsonInclude.Include.ALWAYS,
             Class<?> valueFilter = Void.class,
             Class<?> contentFilter = Void.class)
public @interface JsonInclude {
    enum Include { ALWAYS, NON_NULL, NON_ABSENT, NON_EMPTY, NON_DEFAULT, CUSTOM, USE_DEFAULTS }
}

Inclusion and Exclusion

Object Structure

Annotations that modify how objects are structured in JSON, including unwrapping nested objects and controlling value representation.

@JsonUnwrapped(boolean enabled = true, String prefix = "", String suffix = "")
public @interface JsonUnwrapped;

@JsonValue(boolean value = true)
public @interface JsonValue;

@JsonRawValue(boolean value = true)
public @interface JsonRawValue;

Object Structure

Object Creation and Injection

Control how objects are created during deserialization, including constructor/factory method selection and dependency injection.

@JsonCreator(JsonCreator.Mode mode = JsonCreator.Mode.DEFAULT)
public @interface JsonCreator {
    enum Mode { DEFAULT, DELEGATING, PROPERTIES, DISABLED }
}

@JacksonInject(String value = "", OptBoolean useInput = OptBoolean.DEFAULT)
public @interface JacksonInject;

Object Creation

Polymorphic Type Handling

Comprehensive support for handling polymorphic types with type information inclusion and subtype registration.

@JsonTypeInfo(use = JsonTypeInfo.Id.NONE, include = JsonTypeInfo.As.PROPERTY,
              property = "", Class<?> defaultImpl = JsonTypeInfo.class,
              boolean visible = false,
              OptBoolean requireTypeIdForSubtypes = OptBoolean.DEFAULT)
public @interface JsonTypeInfo {
    enum Id { NONE, CLASS, MINIMAL_CLASS, NAME, SIMPLE_NAME, DEDUCTION, CUSTOM }
    enum As { PROPERTY, WRAPPER_OBJECT, WRAPPER_ARRAY, EXTERNAL_PROPERTY, EXISTING_PROPERTY }
}

@JsonSubTypes(JsonSubTypes.Type[] value, boolean failOnRepeatedNames = false)
public @interface JsonSubTypes {
    @interface Type {
        Class<?> value();
        String name() default "";
        String[] names() default {};
    }
}

Polymorphic Types

Object Identity and References

Handle circular references and object identity with configurable ID generation and reference management.

@JsonIdentityInfo(String property = "@id",
                  Class<? extends ObjectIdGenerator<?>> generator,
                  Class<? extends ObjectIdResolver> resolver = SimpleObjectIdResolver.class,
                  Class<?> scope = Object.class)
public @interface JsonIdentityInfo;

@JsonManagedReference(String value = "defaultReference")
public @interface JsonManagedReference;

@JsonBackReference(String value = "defaultReference")
public @interface JsonBackReference;

Object Identity

Formatting and Serialization Control

Control serialization format for dates, numbers, and other values with comprehensive formatting options.

@JsonFormat(String pattern = "", JsonFormat.Shape shape = JsonFormat.Shape.ANY,
            String locale = JsonFormat.DEFAULT_LOCALE,
            String timezone = JsonFormat.DEFAULT_TIMEZONE,
            OptBoolean lenient = OptBoolean.DEFAULT,
            JsonFormat.Feature[] with = {},
            JsonFormat.Feature[] without = {})
public @interface JsonFormat {
    enum Shape { ANY, NATURAL, SCALAR, ARRAY, OBJECT, NUMBER, NUMBER_FLOAT, 
                 NUMBER_INT, STRING, BOOLEAN, BINARY }
}

@JsonEnumDefaultValue
public @interface JsonEnumDefaultValue;

Formatting

Configuration and Meta-Annotations

Auto-detection configuration, filtering, and meta-annotation support for creating custom annotation combinations.

@JsonAutoDetect(JsonAutoDetect.Visibility getterVisibility = JsonAutoDetect.Visibility.DEFAULT,
                JsonAutoDetect.Visibility isGetterVisibility = JsonAutoDetect.Visibility.DEFAULT,
                JsonAutoDetect.Visibility setterVisibility = JsonAutoDetect.Visibility.DEFAULT,
                JsonAutoDetect.Visibility creatorVisibility = JsonAutoDetect.Visibility.DEFAULT,
                JsonAutoDetect.Visibility fieldVisibility = JsonAutoDetect.Visibility.DEFAULT)
public @interface JsonAutoDetect {
    enum Visibility { ANY, NON_PRIVATE, PROTECTED_AND_PUBLIC, PUBLIC_ONLY, NONE, DEFAULT }
}

@JsonClassDescription(String value = "")
public @interface JsonClassDescription;

Configuration

Supporting Types

Core enums and utility classes used throughout the annotation system:

public enum OptBoolean {
    TRUE, FALSE, DEFAULT;
    
    public boolean asBoolean();
    public boolean asPrimitive();
    public static OptBoolean fromBoolean(Boolean b);
}

public enum Nulls {
    SET, SKIP, FAIL, AS_EMPTY, DEFAULT
}

public enum PropertyAccessor {
    GETTER, SETTER, CREATOR, FIELD, IS_GETTER, NONE, ALL;
    
    public boolean creatorEnabled();
    public boolean getterEnabled();
    public boolean isGetterEnabled();
    public boolean setterEnabled();
    public boolean fieldEnabled();
}

// JsonFormat constants
public static final String DEFAULT_LOCALE = "##default";
public static final String DEFAULT_TIMEZONE = "##default";