Skip to content

feat(json): add Kotlin JSON support - #3937

Merged
chaokunyang merged 24 commits into
apache:mainfrom
chaokunyang:add_json_support_for_kotlin
Aug 20, 2026
Merged

feat(json): add Kotlin JSON support#3937
chaokunyang merged 24 commits into
apache:mainfrom
chaokunyang:add_json_support_for_kotlin

Conversation

@chaokunyang

@chaokunyang chaokunyang commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator

Why?

Kotlin/JVM models carry constructor defaults, nullability, unsigned and value-class semantics,
sealed hierarchies, and complete generic type information that Java Class tokens cannot express.
This PR adds an optional Kotlin JSON module while keeping the existing Java JSON APIs and Fory
binary protocols unchanged.

What does this PR do?

  • Adds fory-json-kotlin with ForyJsonKotlin.builder() and reusable jsonTypeRef<T>() tokens for
    Kotlin object models, defaults, nullability, generics, value classes, unsigned types, sealed
    hierarchies, Mixin overlays, custom codecs, and supported Kotlin/JVM built-ins.
  • Extends the shared JSON resolver, object model, and generated capability paths so language-owned
    metadata can retain direct generated readers and writers, exact semantic types, nullability, and
    primitive/no-box value-class carriers.
  • Adds fory-json-kotlin-ksp as a retention-only processor that emits exact R8/ProGuard rules for
    @JsonType and Kotlin-owned @JsonMixin declarations; it does not generate codecs or application
    classes.
  • Adds a small shared JVM/Android/GraalVM corpus covering defaults, value classes and unsigned
    values, sealed types, Mixins, custom codecs, and generics, plus JPMS and release wiring.
  • Adds Kotlin JSON documentation and a standalone Gradle/JMH benchmark project for Fory,
    kotlinx.serialization, Moshi, and Jackson Kotlin. Benchmark timing is not part of CI.

Related issues

N/A.

AI Contribution Checklist

  • Substantial AI assistance was used in this PR: yes / no
  • If yes, I included a completed AI Contribution Checklist in this PR description and the required AI Usage Disclosure.
  • If yes, my PR description includes the required ai_review summary and screenshot evidence or equivalent persisted links of the final clean AI review results from both fresh reviewers described in AI_POLICY.md, the Fory-guided reviewer and the independent general reviewer, on the current PR diff or current HEAD after the latest code changes.

Does this PR introduce any user-facing change?

Yes. It adds the optional Kotlin/JVM JSON runtime, Kotlin type-token and builder APIs, Android
retention-rule processor, documentation, and platform setup described above.

  • Does this PR introduce any public API change?
  • Does this PR introduce any binary protocol compatibility change?

Benchmark

@chaokunyang
chaokunyang force-pushed the add_json_support_for_kotlin branch from e03b920 to 842a947 Compare August 20, 2026 08:13
@chaokunyang
chaokunyang merged commit d2c46d5 into apache:main Aug 20, 2026
73 checks passed
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