Annotation Interface JsonTypeName


@Target(TYPE) @Retention(RUNTIME) @Documented public @interface JsonTypeName
JSON Type Name - Logical Type Name for Polymorphic Handling JSON 类型名 - 多态处理的逻辑类型名

This annotation defines the logical type name for a class used in polymorphic type handling. The name is used as the type identifier when JsonTypeInfo.Id.NAME is selected as the identifier mechanism.

此注解定义用于多态类型处理的类的逻辑类型名。当选择 JsonTypeInfo.Id.NAME 作为标识机制时,该名称用作类型标识符。

Example | 示例:

@JsonTypeName("dog")
public class Dog extends Animal {
    private String breed;
}

@JsonTypeName("cat")
public class Cat extends Animal {
    private boolean indoor;
}

Features | 主要功能:

Security | 安全性:

  • Thread-safe: Yes (immutable) - 线程安全: 是(不可变)
  • Null-safe: N/A - 空值安全: 不适用
Since:
JDK 25, opencode-base-json V1.0.0
Author:
Leon Soo www.LeonSoo.com
See Also:
  • Optional Element Summary

    Optional Elements
    Modifier and Type
    Optional Element
    Description
    The logical type name for this class.
  • Element Details

    • value

      String value
      The logical type name for this class. 此类的逻辑类型名。
      Returns:
      the logical name, or empty for default (typically simple class name) - 逻辑名,空则使用默认值(通常为简单类名)
      Default:
      ""