Skip to content

feat: add fastjson2-extension-vertx module#4002

Open
jujn wants to merge 10 commits intoalibaba:mainfrom
jujn:feat_3994
Open

feat: add fastjson2-extension-vertx module#4002
jujn wants to merge 10 commits intoalibaba:mainfrom
jujn:feat_3994

Conversation

@jujn
Copy link
Copy Markdown
Collaborator

@jujn jujn commented Mar 1, 2026

What this PR does / why we need it?

功能概述
新增对 Vert.x 5 的原生支持。基于 Vert.x JSON SPI 机制 (io.vertx.core.spi.json.JsonFactory) 提供 Fastjson2 的底层实现,允许用户平滑替换 Vert.x 默认的 Jackson 解析引擎。

整合工作

  • 引擎替换:对齐 Vert.x 5 官方内置 io.vertx.core.json.jackson 包的核心逻辑,提供针对 JsonObject、JsonArray、Buffer 等 Vert.x 专用类型的 Fastjson2 编解码实现。
  • 测试覆盖:移植并适配 Vert.x 官方内置的 JSON 测试套件,确保核心功能的兼容性(跳过个位数测试用例,即在测试类中进行注释,详见下面“兼容性说明”);并加入新的测试来检验 Fastjson2 与 Jackson 行为对齐(CodecAlignmentTest)
  • 性能验证:在 Vert.x 官方内置 JSON Benchmark 中集成 Fastjson2 实现,提供性能对比测试参考(测试 JSON 数据也来自官方)。

兼容性说明
当前实现已对齐 Vert.x 的绝大部分标准行为。受限于 Fastjson2 与 Jackson 底层解析架构的固有差异,少数边界场景(如容错处理、格式化输出等)可能与默认行为存在微小差异。

@jujn jujn marked this pull request as ready for review March 9, 2026 09:32
@wenshao
Copy link
Copy Markdown
Member

wenshao commented Mar 9, 2026

构建通不过?

Comment on lines -454 to +455
boolean fieldBased = (writerFieldFeatures & JSONWriter.Feature.FieldBased.mask) != 0;
boolean fieldBased = ((writerFieldFeatures & JSONWriter.Feature.FieldBased.mask) != 0 && !objectClass.isInterface())
|| !beanInfo.alphabetic;
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这里修复 creator=reflect 时,设置 alphabetic=false(序列化对象字段的输出顺序)不生效的问题;同时调整了其它地方,与 creator=asm 保持一致

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants