Annotation Interface JsonRootName
JSON Root Name - Specifies Root Wrapping Name
JSON 根名称 - 指定根包装名称
This annotation specifies the root element name used to wrap the serialized JSON object. This is useful for APIs that expect a root wrapper element, or for XML interoperability.
此注解指定用于包装序列化 JSON 对象的根元素名称。对于期望根包装元素的 API 或 XML 互操作性非常有用。
Example | 示例:
@JsonRootName("user")
public class User {
private String name;
private int age;
}
// Serializes as: {"user":{"name":"Alice","age":30}}
@JsonRootName(value = "item", namespace = "http://example.com/ns")
public class Item {
private String title;
}
Features | 主要功能:
- Root wrapping for serialized output - 序列化输出的根包装
- Optional namespace for XML interop - 可选的 XML 互操作命名空间
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
-
Element Details