For AI agents: the complete documentation index is available at /docs/llms.txt, the full documentation bundle is available at /docs/llms-full.txt, and this page is available as Markdown at /docs/project/java/json.md.
  • 简体中文
  • 2026
  • Json

    Json Schema

    Jackson

    • jackson
      • 多态序列化
        • 注解。@JsonTypeInfo
          • @JsonTypeIdResolver。实现 PolymorphicResolver 接口
          • @JsonSubTypes 注解
        • 手动注册。ObjectMapper#registerSubtypes(NamedType)
      • 自定义序列化器
        • 脱敏&数据权限
        • 格式化。数字(金钱,千|万|亿),日期,字典|枚举转换

    反射

    jackson 反射 api 使用

    ObjectMapper mapper = createMapper();
    JavaType javaType = mapper.constructType(Test.class);
    // JavaType javaType = mapper.getTypeFactory().constructType(Test.class);
    BeanDescription bd = mapper.getSerializationConfig().introspect(javaType);
    bd.findProperties().stream().forEach(bpd -> System.out.println(bpd.getName()));

    注解

    @JsonAnyGetter 和 @JsonAnySetter

    把未知或动态变化的字段通过 Map 序列化和反序列化。常见于 Map<String, Object> ext 属性。

    @JsonRootName

    todo

    @JsonUnwrapped

    todo

    @JsonPOJOBuilder

    todo

    其他

    • JsonPath。类似 xml path 功能,用于快速提取 json 字段内容。
    • zjsonpatch。用于比较两个 json 片段,获取一个 json 相比另一个 json 增加或者减少的信息。可用于数据传输场景,每次只传输变更的数据。也可用于 json merge 功能,将一个 json 应用于另一个 json,实现如果第一条 json 有字段,则使用第一条的,第一条 json 没有而第二条 json 有的,则继续使用第二条的。