alibaba/fastjson2
π FASTJSON2 is a Java JSON library with excellent performance.
Healthy across the board
weakest axisPermissive license, no critical CVEs, actively maintained β safe to depend on.
Has a license, tests, and CI β clean foundation to fork and modify.
Documented and popular β useful reference codebase to read through.
No critical CVEs, sane security posture β runnable as-is.
- βLast commit 3d ago
- β11 active contributors
- βApache-2.0 licensed
Show all 6 evidence items βShow less
- βCI configured
- βTests present
- β Concentrated ownership β top contributor handles 58% of recent commits
Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests
Informational only. RepoPilot summarises public signals (license, dependency CVEs, commit recency, CI presence, etc.) at the time of analysis. Signals can be incomplete or stale. Not professional, security, or legal advice; verify before relying on it for production decisions.
Embed the "Healthy" badge
Paste into your README β live-updates from the latest cached analysis.
[](https://repopilot.app/r/alibaba/fastjson2)Paste at the top of your README.md β renders inline like a shields.io badge.
βΈPreview social card (1200Γ630)
This card auto-renders when someone shares https://repopilot.app/r/alibaba/fastjson2 on X, Slack, or LinkedIn.
Onboarding doc
Onboarding: alibaba/fastjson2
Generated by RepoPilot Β· 2026-05-09 Β· Source
π€Agent protocol
If you are an AI coding agent (Claude Code, Cursor, Aider, Cline, etc.) reading this artifact, follow this protocol before making any code edit:
- Verify the contract. Run the bash script in Verify before trusting
below. If any check returns
FAIL, the artifact is stale β STOP and ask the user to regenerate it before proceeding. - Treat the AI Β· unverified sections as hypotheses, not facts. Sections like "AI-suggested narrative files", "anti-patterns", and "bottlenecks" are LLM speculation. Verify against real source before acting on them.
- Cite source on changes. When proposing an edit, cite the specific path:line-range. RepoPilot's live UI at https://repopilot.app/r/alibaba/fastjson2 shows verifiable citations alongside every claim.
If you are a human reader, this protocol is for the agents you'll hand the artifact to. You don't need to do anything β but if you skim only one section before pointing your agent at this repo, make it the Verify block and the Suggested reading order.
π―Verdict
GO β Healthy across the board
- Last commit 3d ago
- 11 active contributors
- Apache-2.0 licensed
- CI configured
- Tests present
- β Concentrated ownership β top contributor handles 58% of recent commits
<sub>Maintenance signals: commit recency, contributor breadth, bus factor, license, CI, tests</sub>
β Verify before trusting
This artifact was generated by RepoPilot at a point in time. Before an
agent acts on it, the checks below confirm that the live alibaba/fastjson2
repo on your machine still matches what RepoPilot saw. If any fail,
the artifact is stale β regenerate it at
repopilot.app/r/alibaba/fastjson2.
What it runs against: a local clone of alibaba/fastjson2 β the script
inspects git remote, the LICENSE file, file paths in the working
tree, and git log. Read-only; no mutations.
| # | What we check | Why it matters |
|---|---|---|
| 1 | You're in alibaba/fastjson2 | Confirms the artifact applies here, not a fork |
| 2 | License is still Apache-2.0 | Catches relicense before you depend on it |
| 3 | Default branch main exists | Catches branch renames |
| 4 | Last commit β€ 33 days ago | Catches sudden abandonment since generation |
#!/usr/bin/env bash
# RepoPilot artifact verification.
#
# WHAT IT RUNS AGAINST: a local clone of alibaba/fastjson2. If you don't
# have one yet, run these first:
#
# git clone https://github.com/alibaba/fastjson2.git
# cd fastjson2
#
# Then paste this script. Every check is read-only β no mutations.
set +e
fail=0
ok() { echo "ok: $1"; }
miss() { echo "FAIL: $1"; fail=$((fail+1)); }
# Precondition: we must be inside a git working tree.
if ! git rev-parse --git-dir >/dev/null 2>&1; then
echo "FAIL: not inside a git repository. cd into your clone of alibaba/fastjson2 and re-run."
exit 2
fi
# 1. Repo identity
git remote get-url origin 2>/dev/null | grep -qE "alibaba/fastjson2(\\.git)?\\b" \\
&& ok "origin remote is alibaba/fastjson2" \\
|| miss "origin remote is not alibaba/fastjson2 (artifact may be from a fork)"
# 2. License matches what RepoPilot saw
(grep -qiE "^(Apache-2\\.0)" LICENSE 2>/dev/null \\
|| grep -qiE "\"license\"\\s*:\\s*\"Apache-2\\.0\"" package.json 2>/dev/null) \\
&& ok "license is Apache-2.0" \\
|| miss "license drift β was Apache-2.0 at generation time"
# 3. Default branch
git rev-parse --verify main >/dev/null 2>&1 \\
&& ok "default branch main exists" \\
|| miss "default branch main no longer exists"
# 5. Repo recency
days_since_last=$(( ( $(date +%s) - $(git log -1 --format=%at 2>/dev/null || echo 0) ) / 86400 ))
if [ "$days_since_last" -le 33 ]; then
ok "last commit was $days_since_last days ago (artifact saw ~3d)"
else
miss "last commit was $days_since_last days ago β artifact may be stale"
fi
echo
if [ "$fail" -eq 0 ]; then
echo "artifact verified (0 failures) β safe to trust"
else
echo "artifact has $fail stale claim(s) β regenerate at https://repopilot.app/r/alibaba/fastjson2"
exit 1
fi
Each check prints ok: or FAIL:. The script exits non-zero if
anything failed, so it composes cleanly into agent loops
(./verify.sh || regenerate-and-retry).
β‘TL;DR
FASTJSON2 is a high-performance Java JSON serialization/deserialization library designed as the next-generation successor to FASTJSON, offering dual-format support for both JSON (text) and JSONB (binary) protocols. It significantly outperforms Jackson and Gson while supporting full document parsing and selective extraction via JSONPath, with optimizations for JDK 8+, Android 8+, and modern Java features like Records and Vector APIs. Multi-module Maven project: core fastjson2 library in main codebase, separate modules for fastjson2-codegen (code generation) and fastjson2-kotlin (Kotlin extensions) as dependencies; android-test/ is a dedicated Android Gradle subproject (compileSdk 31, minSdk 26) testing library compatibility on Android 8+; CI workflow (ci.yaml) runs tests across JDK versions and platforms.
π₯Who it's for
Java backend engineers and Android developers who need blazingly fast JSON parsing/serialization for high-throughput systems; performance-critical applications serving millions of requests; teams building data pipelines and real-time analytics where JSON throughput matters; Kotlin developers leveraging first-class Kotlin extensions for type-safe JSON operations.
π±Maturity & risk
Production-ready and actively maintained: 10k+ GitHub stars, comprehensive CI/CD via GitHub Actions (.github/workflows/ci.yaml), high codecov coverage tracked (.codecov.yml), multi-platform test coverage (Java, Android, Kotlin). Regular SNAPSHOT releases to Maven Central (v2.0.41-SNAPSHOT visible in dependencies). This is a mature, battle-tested library used across Alibaba's ecosystem.
Standard open source risks apply.
Active areas of work
Active development toward v2.0.x stability: SNAPSHOT versions (2.0.41-SNAPSHOT) being tested in android-test/; Kotlin support being enhanced (fastjson2-kotlin:2.0.40 dependency); Android compatibility validation ongoing across multiple test cases (EishayTest.java, Issue715.java, JSONKtTest.kt, ValueTest.java); dependabot.yml indicates automated dependency management enabled.
πGet running
Clone and build: git clone https://github.com/alibaba/fastjson2.git && cd fastjson2 && ./mvnw clean install. For Android testing: cd android-test && ./gradlew build. Run tests: ./mvnw test or ./mvnw -DskipTests=false clean verify.
Daily commands:
Dev build: ./mvnw clean package. Run unit tests: ./mvnw test. Full test suite with Android: ./mvnw clean verify && cd android-test && ./gradlew connectedAndroidTest (requires Android SDK/emulator). Build snapshot: ./mvnw clean install -DskipTests.
πΊοΈMap of the codebase
- .github/workflows/ci.yaml: CI/CD pipeline defining test matrix across JDK versions and platforms; critical for verifying compatibility claims
- android-test/app/src/androidTest/java/com/alibaba/fastjson2/android/: Android integration tests validating library behavior on actual Android platform (minSdk 26), essential for multi-platform maturity
- .codecov.yml: Code coverage configuration ensuring test quality metrics are tracked across commits
- CONTRIBUTING.md: Contributor guidelines and workflow for external contributors; reference for onboarding process
- android-test/app/build.gradle: Android build configuration with Gradle; shows exact SDK versions (compileSdk 31, minSdk 26, targetSdk 29) and dependencies
π οΈHow to make changes
Core serialization logic: examine main source tree (reference to com.alibaba.fastjson2 package in android tests). Kotlin extensions: modify fastjson2-kotlin module. Android compatibility: add tests to android-test/app/src/androidTest/java/com/alibaba/fastjson2/android/. New features: add to main module, expose via fastjson2-codegen or fastjson2-kotlin as needed. Follow CONTRIBUTING.md and CODE_OF_CONDUCT.md.
πͺ€Traps & gotchas
Android minSdk is 26 (Android 8.0), not all devices supported; SNAPSHOT versions in dependencies (2.0.41-SNAPSHOT) require Sonatype snapshots repository configured; ProGuard rules in android-test/app/proguard-rules.pro must be applied for release builds; dual format support means JSONB output is non-standard (not interoperable with other JSON libraries without custom parsers); .mvn/wrapper uses Maven Wrapper, not system Maven.
π‘Concepts to learn
- JSONB (Binary JSON Format) β FASTJSON2's dual-format capability; understanding the binary serialization format is essential for leveraging performance gains in high-throughput systems
- JSONPath (SQL:2016 Standard) β Core feature for selective JSON extraction without parsing entire documents; enables efficient partial document queries
- Unsafe Memory Operations (sun.misc.Unsafe) β FASTJSON2 uses JVM Unsafe for low-level optimizations; visible in UnsafeTest.java and UnsafeUtilsTest.java in android-test/, critical for understanding performance characteristics
- Code Generation (Codegen) for Serialization β fastjson2-codegen module generates specialized serialization code at compile-time or runtime; avoids reflection overhead in hot paths
- Vector API (JDK 21+) β FASTJSON2 optimizes for modern JDK versions using Vector API for SIMD operations; relevant for performance tuning on JDK 17+
- Compact String Optimization (JDK 9+) β FASTJSON2 leverages JDK 9+ compact string representation (single-byte encoding for Latin-1 strings); improves memory efficiency for JSON strings
- Android ProGuard/R8 Obfuscation β android-test/ includes proguard-rules.pro; necessary for shipping FASTJSON2 in production Android apps to prevent method/field stripping
πRelated repos
FasterXML/jackson-databindβ Direct performance competitor for Java JSON serialization; Jackson is the most common alternative mentioned in benchmarksgoogle/gsonβ Another mainstream Java JSON library and performance baseline; FASTJSON2 explicitly outperforms it per READMEalibaba/fastjsonβ Original FASTJSON (v1.x) β FASTJSON2 is the successor; legacy codebase for users not yet migratedalibaba/druidβ Complementary Alibaba library (JDBC connection pool, SQL parser); often used in same ecosystem for data pipeline projectsKotlin/kotlinx.serializationβ Kotlin's native serialization library; FASTJSON2's Kotlin extensions provide an alternative with higher JSON performance
πͺPR ideas
To work on one of these in Claude Code or Cursor, paste:
Implement the "<title>" PR idea from CLAUDE.md, working through the checklist as the task list.
Add Android API level compatibility tests for API 21-25
The android-test app currently targets minSdk 26, but fastjson2 should support wider Android versions. The existing android-test suite only covers API 26+. Adding instrumented tests for API 21-25 would ensure fastjson2 works reliably across more device generations and increase library adoption. This aligns with the CONTRIBUTING.md guidance for comprehensive testing.
- [ ] Create android-test/app/src/androidTest/java/com/alibaba/fastjson2/android/APICompatibilityTest.java targeting API 21-25 scenarios
- [ ] Add test cases for reflection-based serialization edge cases that differ between API levels (e.g., handling of removed/deprecated Java classes)
- [ ] Update android-test/app/build.gradle to run tests on multiple emulator API levels (21, 23, 25) in addition to current 26+
- [ ] Document any API level-specific workarounds in CONTRIBUTING.md or a new ANDROID_COMPATIBILITY.md file
Add performance regression benchmarks to CI pipeline
The .github/workflows/ci.yaml currently runs tests but lacks performance benchmarks. fastjson2's core value proposition is 'excellent performance', but there's no automated CI check to prevent performance regressions. Adding JMH (Java Microbenchmark Harness) benchmarks to the CI would protect against unintended performance degradation and provide metrics for PRs.
- [ ] Create benchmark module at benchmark/pom.xml with JMH dependencies and existing test JSONs (eishay.json, cart.json, h5api.json, homepage.json from android-test/app/src/main/assets)
- [ ] Add benchmark/src/main/java/com/alibaba/fastjson2/benchmark/SerializationBenchmark.java and DeserializationBenchmark.java testing core parse/toJSONString operations
- [ ] Update .github/workflows/ci.yaml to run benchmarks on baseline branch and compare against PR branch, posting results as PR comments
- [ ] Document benchmark setup and how to run locally in CONTRIBUTING.md
Add Kotlin extension tests for null safety and coroutine integration
The android-test suite includes JSONKtTest.kt but it's minimal. Given that fastjson2-kotlin (v2.0.40) is a first-class module, there should be comprehensive Kotlin-specific tests covering null safety (nullable/non-nullable types), data class serialization edge cases, and potential coroutine integration scenarios. This ensures Kotlin developers have confidence in the library.
- [ ] Expand android-test/app/src/androidTest/java/com/alibaba/fastjson2/android/JSONKtTest.kt with test cases for: nullable properties, lateinit vars, data class defaults, sealed classes, and object serialization
- [ ] Add android-test/app/src/androidTest/java/com/alibaba/fastjson2/android/KotlinNullSafetyTest.kt to verify type safety at compile and runtime (e.g., non-null fields reject null JSON values)
- [ ] Create android-test/app/src/androidTest/java/com/alibaba/fastjson2/android/KotlinDataClassTest.kt with complex nested data class scenarios
- [ ] Update README.md with a 'Kotlin Usage' section referencing these tests and best practices
πΏGood first issues
- Add missing unit tests for JSONB binary format edge cases (e.g., large arrays, deeply nested objects) β examine android-test/ structure and replicate patterns in main test suite
- Expand JSONPath SQL:2016 compatibility documentation with concrete examples in README.md; currently mentioned but no usage examples provided
- Optimize Kotlin extension API surface (fastjson2-kotlin module) by adding reified type parameter overloads to reduce .java<Type>().value boilerplate in common Kotlin use cases
βTop contributors
Click to expand
Top contributors
- @wenshao β 58 commits
- @jujn β 25 commits
- @mengnankkkk β 6 commits
- @Copilot β 3 commits
- @ban-xiu β 2 commits
πRecent commits
Click to expand
Recent commits
3697c2dβ fix: JSONB ASM direct-write under-counted object frame bytes (#7616) (#7617) (wenshao)5a05075β fix: JSONPath syntax error when 'in'/'rlike' filter follows other filters (#3997) (#4030) (wenshao)14ea6eaβ fix: Map subclass loses @type when serialized with ValueFilter (#3984) (#4029) (wenshao)ede10a5β Docs/comprehensive documentation overhaul (#4028) (wenshao)7bceed2β fix: skip whitespace after non-comma in readLocalDate for UTF8 reader (#4005) (mengnankkkk)05e8220β fix: DateUtils multiple bugs β bitwise OR typo, bounds check off-by-one, wrong offset and error message length (wenshao)b3eb46cβ Refactor/improve object reader creator asm (#4021) (wenshao)bbb1d02β fix: IOUtils.regionMatches off-by-one and parseInt error message corruption (#4022) (wenshao)f15dc36β fix: writeFloat(float[]) ArrayIndexOutOfBoundsException when WriteNonStringValueAsString enabled, for issue #1591 (wenshao)f951947β fix: JSONPath nested array filter returning incorrect results, for issue #4007 (#4015) (jujn)
πSecurity observations
- High Β· Outdated Dependency: Jackson Databind β
android-test/app/build.gradle - dependencies section. jackson-databind 2.14.2 contains known vulnerabilities. The package should be updated to the latest patched version (2.15.2 or later). Jackson databind has had multiple CVEs related to deserialization attacks and type handling. Fix: Update jackson-databind to version 2.15.2 or later. Also update jackson-core and jackson-annotations to matching versions. - High Β· SNAPSHOT Version in Production Dependencies β
android-test/app/build.gradle - fastjson2:2.0.41-SNAPSHOT dependency. The Android test app includes 'fastjson2:2.0.41-SNAPSHOT' which is a development snapshot version. Snapshot versions are unstable and may contain unpatched security vulnerabilities. Using snapshots in production or test environments can introduce unpredictable security issues. Fix: Replace the SNAPSHOT version with a stable release version (e.g., 2.0.41 or later stable release). SNAPSHOT versions should only be used in isolated development environments. - High Β· Legacy fastjson 1.x Dependency β
android-test/app/build.gradle - fastjson:1.1.73.android dependency. The dependency 'com.alibaba:fastjson:1.1.73.android' is an outdated version of fastjson 1.x. Fastjson 1.x has known critical vulnerabilities including RCE attacks via deserialization. The entire 1.x line is deprecated in favor of fastjson2. Fix: Remove the fastjson 1.x dependency entirely. Use only fastjson2 which is the maintained and secure version. - Medium Β· Outdated Kotlin Standard Library β
android-test/app/build.gradle - kotlin dependencies. kotlin-stdlib and kotlin-reflect are pinned to version 1.8.10, which is outdated. Newer Kotlin versions include security patches and bug fixes. Current stable is 1.9.x+. Fix: Update Kotlin stdlib and reflect to version 1.9.x or latest stable version. - Medium Β· Outdated Android SDK Targets β
android-test/app/build.gradle - android.compileSdk and targetSdk. The Android configuration uses compileSdk 31 and targetSdk 29, which are significantly outdated. Current recommendations are SDK 33+. Older SDKs lack recent security patches and Google Play requires targetSdk 31+ (now enforced to 33+). Fix: Update compileSdk to 34 and targetSdk to 34. Update minSdk if possible (current 26 is very old). - Medium Β· Outdated AndroidX Dependencies β
android-test/app/build.gradle - AndroidX dependencies. Android dependencies are outdated: appcompat 1.4.0, material 1.4.0, and constraintlayout 2.1.1 are significantly behind current versions. These libraries contain security fixes in newer versions. Fix: Update to: appcompat 1.6.1+, material 1.10.0+, constraintlayout 2.1.4+ (or later). - Medium Β· Outdated Test Dependencies β
android-test/app/build.gradle - test dependencies. Test dependencies are outdated: junit 5.9.2, androidx.test.ext:junit 1.1.3, and espresso-core 3.3.0 are behind current versions which may have security implications. Fix: Update to latest versions: junit 5.9.3+, androidx.test.ext:junit 1.1.5+, espresso-core 3.5.1+. - Low Β· Missing ProGuard Configuration Review β
android-test/app/proguard-rules.pro. While minifyEnabled is false in release build (allowing code inspection), the proguard-rules.pro file should be reviewed to ensure it's properly configured if minification is enabled in production. Fix: Review and properly configure ProGuard rules. Consider enabling minification in release builds with appropriate rules to obfuscate
LLM-derived; treat as a starting point, not a security audit.
πWhere to read next
- Open issues β current backlog
- Recent PRs β what's actively shipping
- Source on GitHub
Generated by RepoPilot. Verdict based on maintenance signals β see the live page for receipts. Re-run on a new commit to refresh.