Annotation Interface JsonIgnore


@Target({FIELD,METHOD}) @Retention(RUNTIME) @Documented public @interface JsonIgnore
JSON Ignore - Excludes Field from JSON Processing JSON 忽略 - 从 JSON 处理中排除字段

This annotation marks a field to be excluded from JSON serialization and/or deserialization.

此注解标记字段从 JSON 序列化和/或反序列化中排除。

Example | 示例:

public class User {
    private String username;

    @JsonIgnore
    private String password;  // Never serialized or deserialized

    @JsonIgnore(serialize = false)
    private String tempToken; // Only deserialized, never serialized
}

Features | 主要功能:

  • Selective serialization/deserialization exclusion - 选择性序列化/反序列化排除
  • Independent control for read and write directions - 读写方向的独立控制

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
    boolean
    Whether to ignore during deserialization.
    boolean
    Whether to ignore during serialization.
  • Element Details

    • serialize

      boolean serialize
      Whether to ignore during serialization. 是否在序列化时忽略。
      Returns:
      true to ignore during serialization - 如果在序列化时忽略则返回 true
      Default:
      true
    • deserialize

      boolean deserialize
      Whether to ignore during deserialization. 是否在反序列化时忽略。
      Returns:
      true to ignore during deserialization - 如果在反序列化时忽略则返回 true
      Default:
      true