Support JSON binding with the JDK's built-in JSON API (`jdk.incubator.json`)
维护者通常 1 天内回复
还没有人认领这个 Issue。
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 25/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 活跃
- 技术栈
- java, json
调研方向
Read the linked proposal and inspect the prototype’s JsonRecordHttpMessageConverter to understand the proposed mapping and constraints. Compare the reflection, generated, hybrid, and tree-only options for spring-web and spring-messaging; done means the project has a decided scope and approach, or has explained why this belongs in a separate library.
由索引模型根据 Issue 内容生成。
描述
Use case
I want to build Spring MVC REST endpoints that read and write Java records as JSON without a third-party JSON library:
@PostMapping("/hello")
public HelloResponse hello(@RequestBody HelloRequest request) { ... }
The same records should also work as Kafka message payloads:
@KafkaListener(topics = "hello")
public void onHello(HelloRequest request) { ... }
JDK 28 ships an incubating JSON API (jdk.incubator.json) that parses JSON into a JsonValue tree and writes it back, but it does not map JSON to Java types.
Spring has HTTP and messaging converters for Jackson, Gson, JSON-B and Kotlin Serialization, but none for the JDK API.
Reasons for a JDK-only option:
- Fewer dependencies for applications that only need simple JSON.
- A smaller attack surface:
jackson-databindhas 86 advisories in OSV, 17 of them published in 2026. - GraalVM native images without reflection metadata for the JSON library.
What I have tried so far
A prototype on Spring Boot 4.1 / JDK 28-ea: https://github.com/drnow4u/springboot-jdk28-json
JsonRecordHttpMessageConverter, anAbstractHttpMessageConverter<Record>that maps JSON objects to and from records using reflection over record components (String, numeric and boolean types, nested records).- Malformed JSON or a wrong value type is mapped to
HttpMessageNotReadableException(400). - The JDK parser has no size limits and repeats the offending input in its error messages, so the converter limits the body size (
413) and shortens error messages. - Spring AOT already registers reflection hints for the records used in the controller signature, so option A below may work in a native image; this cannot be verified until GraalVM supports JDK 28.
Questions
The main design question is how the mapping should work:
- A. Reflection over record components (what the prototype does). No setup, but needs AOT hints for native images.
- B. Compile-time generated bindings (annotation processor), similar to Kotlin Serialization. No reflection, errors at compile time, but needs a processor on the build path.
- C. Hybrid: generated bindings when present, reflection otherwise.
- D. Tree types only: a converter for
JsonValue/JsonObject/JsonArray, with mapping left to applications or libraries.
Whichever option is chosen, the mapping would be shared by an HttpMessageConverter (spring-web) and a MessageConverter (spring-messaging, used by @KafkaListener); a Kafka Serializer/Deserializer would belong in Spring for Apache Kafka.
Would the Spring team consider any of these for Spring Framework, and which one? Or should this live in a separate library until the JDK API leaves incubation?
The full proposal, covering security, performance, native image and open questions, is here:
https://github.com/drnow4u/springboot-jdk28-json/blob/main/docs/proposal-jdk-json-binding.md
- 主要语言
- Java
- 星标
- 60.3k
- 派生
- 38.7k
- 平均合并
- 1 天 14 小时
- 30 天内合并 PR
- 34
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
spring-projects/spring-framework 的其他 Issue
-
PropertyEditorRegistrySupport.createDefaultEditors is not thread-safe when a registry is shared across threads可能已有人在做 @codingkush 于 1 天前认领。 未关闭status: waiting-for-triage
难度 2/5 1-3 小时 新手友好度 78/100
spring-projects/spring-framework#37614 · 1 条评论 ·
维护者通常 1 天内回复
-
status: waiting-for-triage
难度 2/5 1-3 小时 新手友好度 87/100
spring-projects/spring-framework#37613 ·
维护者通常 1 天内回复
-
in: core status: waiting-for-triage
难度 2/5 1-3 小时 新手友好度 82/100
spring-projects/spring-framework#37612 ·
维护者通常 1 天内回复
-
`YamlProcessor.getFlattenedMap` with `includeEmpty` returns a `null` key for an empty root mapping可能重新可做 @erfannvb 于 13 天前认领,目前没有进行中的 PR。 未关闭status: waiting-for-triage
难度 2/5 1-3 小时 新手友好度 78/100
spring-projects/spring-framework#37522 · 1 条评论 ·
维护者通常 1 天内回复
-
`WebClient` with default codecs drops `ProblemDetail` extension members可能重新可做 关联的 PR 已关闭且未合并。 未关闭status: waiting-for-triage
难度 2/5 1-3 小时 新手友好度 70/100
spring-projects/spring-framework#37503 · 1 条评论 ·
维护者通常 1 天内回复
查看 spring-projects/spring-framework 的全部 Issue
相似的 Issue
-
bug
难度 2/5 1-3 小时 新手友好度 72/100
liberation-data/drivine4j#547 ·
维护者通常 1 天内回复
-
enhancement
难度 2/5 1-3 小时 新手友好度 70/100
-
BindingServiceProperties.bindings regressed to a non-thread-safe TreeMap in GH-3158: concurrent first use of binding names corrupts it可能已有人在做 @AkashB23 今天认领。 未关闭
难度 2/5 1-3 小时 新手友好度 62/100
spring-cloud/spring-cloud-stream#3321 ·
维护者通常 1 天内回复
-
[Bug] 资源包列表 与 模组/数据包/世界 列表排列顺序不一致可能已有人在做 @fishdry1000 于 4 天前认领。 未关闭bug
难度 2/5 1-3 小时 新手友好度 62/100
维护者通常 1 天内回复
-
ai-driven-fuzzing bug claude Minor
难度 2/5 1-3 小时 新手友好度 72/100
linagora/twake-calendar-side-service#1333 ·
维护者通常 1 天内回复