Annotation Interface JsonRawValue
JSON Raw Value - Includes String Value as Raw JSON
JSON 原始值 - 将字符串值作为原始 JSON 包含
This annotation marks a field or method whose String value should
be included verbatim as raw JSON output, without quoting or escaping.
This is useful when a field already contains pre-serialized JSON.
此注解标记一个字段或方法,其 String 值将按原样作为原始 JSON 输出,
不进行引号包裹或转义。当字段已包含预序列化的 JSON 时非常有用。
Example | 示例:
public class Event {
private String name;
@JsonRawValue
private String payload = "{\"key\":\"value\"}";
}
// Serializes as: {"name":"click","payload":{"key":"value"}}
// NOT: {"name":"click","payload":"{\"key\":\"value\"}"}
Features | 主要功能:
- Embeds pre-serialized JSON without extra quoting - 嵌入预序列化的 JSON,不添加额外引号
- Can be disabled via
value = false- 可通过value = false禁用
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 ElementsModifier and TypeOptional ElementDescriptionbooleanWhether the raw value behavior is enabled.
-
Element Details
-
value
boolean valueWhether the raw value behavior is enabled. 是否启用原始值行为。- Returns:
- true if raw value output is enabled - 如果启用原始值输出则返回 true
- Default:
true
-