Technical Documentation: alibaba/fastjson2
ℹ️ Provenance: Multi-Tier Ingestion · CodeWiki Reference
Overview (`README.md`)
Language: English | [中文](README_cn.md)
FASTJSON 2
FASTJSON 2 is a high-performance JSON library for Java, designed as the next-generation successor to FASTJSON with a goal of providing an optimized JSON solution for the next ten years.
Highlights
- Blazing Fast - Significantly outperforms Jackson, Gson, and org.json. Benchmarks
- Dual Format - Native support for both JSON (text) and JSONB (binary) protocols
- Full & Partial Parsing - Complete document parsing or selective extraction via JSONPath (SQL:2016 compatible)
- Modern Java - Optimized for JDK 8/11/17/21 with compact string, Record, and Vector API support
- Multi-Platform - Works on Java servers, Android 8+ clients, and big data pipelines
- Kotlin Native - First-class Kotlin extensions with idiomatic DSL-style API
- JSON Schema - Built-in validation support with high performance
- Secure by Default - AutoType disabled by default; no hardcoded whitelist; SafeMode support
- GraalVM Ready - Compatible with GraalVM Native Image
Table of Contents
- Quick Start
- Installation
- Basic Usage
- Advanced Usage
- Upgrading from Fastjson 1.x
- Documentation
- Contributing
Quick Start
Add the dependency and start parsing JSON in seconds:
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.66</version>
</dependency>import com.alibaba.fastjson2.JSON;
// Parse
User user = JSON.parseObject("{\"name\":\"John\",\"age\":25}", User.class);
// Serialize
String json = JSON.toJSONString(user);1. Installation
1.1 Core Library
The groupId for FASTJSON 2 is com.alibaba.fastjson2 (different from 1.x):
Maven:
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.66</version>
</dependency>Gradle:
dependencies {
implementation 'com.alibaba.fastjson2:fastjson2:2.0.66'
}Find the latest version on Maven Central.
1.2 Fastjson v1 Compatibility Module
If you are migrating from fastjson 1.2.x, you can use the compatibility package as a drop-in replacement. Note that 100% compatibility is not guaranteed - please test thoroughly and report issues.
Maven:
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>2.0.66</version>
</dependency>Gradle:
dependencies {
implementation 'com.alibaba:fastjson:2.0.66'
}1.3 Kotlin Module
For projects using Kotlin, the fastjson2-kotlin module provides idiomatic Kotlin extensions:
Maven:
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-kotlin</artifactId>
<version>2.0.66</version>
</dependency>Add the Kotlin standard library and reflection library as needed. The reflection library is required when using data classes or constructor-based parameter passing:
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin-version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>${kotlin-version}</version>
</dependency>Kotlin Gradle:
dependencies {
implementation("com.alibaba.fastjson2:fastjson2-kotlin:2.0.66")
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version")
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")
}1.4 Spring Framework Integration
For Spring Framework projects, use the appropriate extension module. See the full Spring Integration Guide for details.
Maven (Spring 5.x):
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-extension-spring5</artifactId>
<version>2.0.66</version>
</dependency>Maven (Spring 6.x):
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-extension-spring6</artifactId>
<version>2.0.66</version>
</dependency>Gradle:
dependencies {
// Choose one based on your Spring version:
implementation 'com.alibaba.fastjson2:fastjson2-extension-spring5:2.0.66'
// or
implementation 'com.alibaba.fastjson2:fastjson2-extension-spring6:2.0.66'
}2. Basic Usage
The package name for FASTJSON 2 is
com.alibaba.fastjson2. If upgrading from v1, simply update the package imports.
2.1 Parse JSON to `JSONObject`
Java:
String text = "{\"id\":1,\"name\":\"fastjson2\"}";
JSONObject data = JSON.parseObject(text);
byte[] bytes = text.getBytes(StandardCharsets.UTF_8);
JSONObject data = JSON.parseObject(bytes);Kotlin:
import com.alibaba.fastjson2.*
val text = """{"id":1,"name":"fastjson2"}"""
val data = text.parseObject()
val bytes: ByteArray = text.toByteArray()
val data = bytes.parseObject() // JSONObject2.2 Parse JSON to `JSONArray`
Java:
String text = "[{\"id\":1},{\"id\":2}]";
JSONArray data = JSON.parseArray(text);Kotlin:
import com.alibaba.fastjson2.*
val text = """[{"id":1},{"id":2}]"""
val data = text.parseArray() // JSONArray2.3 Parse JSON to Java Object
Java:
String text = "{\"id\":1,\"name\":\"John\"}";
User user = JSON.parseObject(text, User.class);Kotlin:
import com.alibaba.fastjson2.*
val text = """{"id":1,"name":"John"}"""
val user = text.to<User>() // User
val user = text.parseObject<User>() // User (alternative)2.4 Serialize Java Object to JSON
Java:
User user = new User(1, "John");
String text = JSON.toJSONString(user); // String output
byte[] bytes = JSON.toJSONBytes(user); // byte[] outputKotlin:
import com.alibaba.fastjson2.*
val user = User(1, "John")
val text = user.toJSONString() // String
val bytes = user.toJSONByteArray() // ByteArray2.5 Working with `JSONObject` and `JSONArray`
2.5.1 Get Simple Properties
String text = "{\"id\": 2, \"name\": \"fastjson2\"}";
JSONObject obj = JSON.parseObject(text);
int id = obj.getIntValue("id");
String name = obj.getString("name");String text = "[2, \"fastjson2\"]";
JSONArray array = JSON.parseArray(text);
int id = array.getIntValue(0);
String name = array.getString(1);2.5.2 Get JavaBean from JSON Containers
Java:
JSONArray array = ...;
JSONObject obj = ...;
User user = array.getObject(0, User.class);
User user = obj.getObject("key", User.class);Kotlin:
val array: JSONArray = ...
val obj: JSONObject = ...
val user = array.to<User>(0)
val user = obj.to<User>("key")2.5.3 Convert JSONObject/JSONArray to JavaBean
Java:
JSONObject obj = ...;
JSONArray array = ...;
User user = obj.toJavaObject(User.class);
List<User> users = array.toJavaList(User.class);Kotlin:
val obj: JSONObject = ...
val array: JSONArray = ...
val user = obj.to<User>() // User
val users = array.toList<User>() // List<User>2.6 Serialize JavaBean to JSON
Java:
class User {
public int id;
public String name;
}
User user = new User();
user.id = 2;
user.name = "FastJson2";
String text = JSON.toJSONString(user);
byte[] bytes = JSON.toJSONBytes(user);Kotlin:
class User(
var id: Int,
var name: String
)
val user = User(2, "FastJson2")
val text = user.toJSONString() // String
val bytes = user.toJSONByteArray() // ByteArrayOutput:
{"id":2,"name":"FastJson2"}3. Advanced Usage
3.1 JSONB Binary Format
JSONB is a high-performance binary JSON format that provides significantly faster serialization/deserialization and smaller payload sizes. See the JSONB Format Specification.
Serialize to JSONB
User user = ...;
byte[] bytes = JSONB.toBytes(user);
byte[] bytes = JSONB.toBytes(user, JSONWriter.Feature.BeanToArray); // Even more compactParse JSONB
byte[] bytes = ...;
User user = JSONB.parseObject(bytes, User.class);
User user = JSONB.parseObject(bytes, User.class, JSONReader.Feature.SupportArrayToBean);3.2 JSONPath
JSONPath enables partial parsing of JSON documents without full deserialization, which is ideal for extracting specific fields from large payloads. FASTJSON 2 implements SQL:2016 JSONPath syntax.
Extract from String
String text = ...;
JSONPath path = JSONPath.of("$.id"); // Cache and reuse for better performance
JSONReader parser = JSONReader.of(text);
Object result = path.extract(parser);Extract from byte[]
byte[] bytes = ...;
JSONPath path = JSONPath.of("$.id"); // Cache and reuse for better performance
JSONReader parser = JSONReader.of(bytes);
Object result = path.extract(parser);Extract from JSONB byte[]
byte[] bytes = ...;
JSONPath path = JSONPath.of("$.id"); // Cache and reuse for better performance
JSONReader parser = JSONReader.ofJSONB(bytes); // Note: use ofJSONB method
Object result = path.extract(parser);See the full JSONPath Documentation for filter expressions, aggregate functions, array slicing, and more.
3.3 Features Configuration
FASTJSON 2 provides fine-grained control over serialization and deserialization behavior through JSONWriter.Feature and JSONReader.Feature. All features are OFF by default.
// Serialization with features
String json = JSON.toJSONString(user,
JSONWriter.Feature.WriteNulls,
JSONWriter.Feature.PrettyFormat);
// Deserialization with features
User user = JSON.parseObject(json, User.class,
JSONReader.Feature.SupportSmartMatch);See the full Features Reference for all available options and migration mapping from fastjson 1.x.
3.4 Annotations
Use @JSONField and @JSONType to customize serialization/deserialization behavior:
public class User {
@JSONField(name = "user_name", ordinal = 1)
public String name;
@JSONField(format = "yyyy-MM-dd", ordinal = 2)
public Date birthday;
@JSONField(serialize = false)
public String password;
}See the full Annotations Guide.
3.5 Custom Serializer/Deserializer
Implement ObjectWriter<T> or ObjectReader<T> for custom serialization logic:
// Custom writer
class MoneyWriter implements ObjectWriter<Money> {
public void write(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features) {
Money money = (Money) object;
jsonWriter.writeString(money.getCurrency() + " " + money.getAmount());
}
}
// Register
JSON.register(Money.class, new MoneyWriter());See the full Custom Reader/Writer Guide.
3.6 Filters
FASTJSON 2 provides a comprehensive filter system for serialization:
| Filter | Purpose |
|---|---|
ValueFilter |
Transform property values |
NameFilter |
Rename properties |
PropertyFilter |
Include/exclude properties conditionally |
AfterFilter / BeforeFilter |
Inject additional content |
LabelFilter |
Scenario-based serialization |
ContextValueFilter / ContextNameFilter |
Context-aware transformations |
See the full Filter Documentation.
4. Upgrading from Fastjson 1.x
FASTJSON 2 provides both a compatibility mode (drop-in replacement) and a new API mode for upgrading. Key changes:
| Aspect | Fastjson 1.x | Fastjson 2.x |
|---|---|---|
| Package | com.alibaba.fastjson |
com.alibaba.fastjson2 |
| GroupId | com.alibaba |
com.alibaba.fastjson2 |
| AutoType | Enabled with whitelist | Disabled by default (more secure) |
| Circular Reference | Detected by default | Not detected by default |
| Smart Match | On by default | Off by default |
| Default Features | Multiple features on | All features off |
See the full Migration Guide for step-by-step instructions, API mapping table, and common issues.
5. Documentation
Core References
| Document | Description |
|---|---|
| Features Reference | Complete list of JSONReader/JSONWriter features |
| Annotations Guide | @JSONField, @JSONType, @JSONCreator usage |
| Architecture | Internal architecture, design patterns, and class hierarchy |
| FAQ | Frequently asked questions and troubleshooting |
Format & Protocol
| Document | Description |
|---|---|
| JSONB Format | Binary JSON format specification |
| JSONB vs Hessian/Kryo | Performance comparison with other binary formats |
| JSONB Size Comparison | Payload size comparison |
| CSV Support | CSV reading and writing support |
JSONPath
| Document | Description |
|---|---|
| JSONPath Guide | Syntax, operators, and examples |
| Multi-value JSONPath | Multi-value extraction |
| Typed JSONPath | Type-safe JSONPath extraction |
| JSONPath Benchmark | Performance data |
Integrations
| Document | Description |
|---|---|
| Spring Support | Spring MVC, WebFlux, Data Redis, Messaging |
| Kotlin Extensions | Kotlin API and DSL |
| Android Support | Android 8+ integration |
Customization
| Document | Description |
|---|---|
| Custom Reader/Writer | Implement ObjectReader/ObjectWriter |
| MixIn Annotations | Inject annotations on third-party classes |
| AutoType Security | AutoType mechanism and security configuration |
| JSON Schema | Schema validation |
| Filter System | Serialization filters |
Migration & Performance
| Document | Description |
|---|---|
| v1 to v2 Migration | Upgrade guide with API mapping |
| Performance Guide | Tuning tips and best practices |
| Benchmarks | Comprehensive benchmark results |
6. Contributing
We welcome contributions of all kinds - bug reports, feature requests, documentation improvements, and code contributions.
- See CONTRIBUTING.md for development setup, coding standards, and the pull request process
- See CODE_OF_CONDUCT.md for community guidelines
- See SECURITY.md for reporting security vulnerabilities
Star History
Overview (`example-solon-test/README.md`)
启动方式
运行 SolonTestApp.main 方法(或者直接运行单测 DemoTest )
测试
测试 Render 是否正常工作
测试 找不到的地址异常(技术上和上面一样,Solon 所有的 Web 输出都会走:Render 接口)
说明
此演示,会自动触发 fastjson2-extension-solon 的:
- Fastjson2RenderFactory
- Fastjson2ActionExecutor
Overview (`example-spring-test/README.md`)
启动方式
运行SpringTestApplication.main方法即可
测试
访问http://localhost:8080/test?username=123&password=456,测试HttpMessageConverter是否正常工作。
访问http://localhost:8080/hello进入一个聊天页面,测试websocket是否正常工作。
访问任意找不到的地址,即可测试FastJsonJsonView,错误页面已经使用FastJsonJsonView。
Overview (`example-spring6-test/README.md`)
启动方式
运行SpringTestApplication.main方法即可
测试
访问http://localhost:8080/test?username=123&password=456,测试HttpMessageConverter是否正常工作。
访问http://localhost:8080/hello进入一个聊天页面,测试websocket是否正常工作。
访问任意找不到的地址,即可测试FastJsonJsonView,错误页面已经使用FastJsonJsonView。
Index (`docs/index.md`)
0. FASTJSON 2.0介绍
FASTJSON v2是FASTJSON项目的重要升级,目标是为下一个十年提供一个高性能的JSON库。通过同一套API,
- 支持
JSON/JSONB两种协议,JSONPath是一等公民。 - 支持全量解析和部分解析。
- 支持
Java服务端、客户端Android、大数据场景。 - 支持
Kotlin - 支持
JSON Schemahttps://alibaba.github.io/fastjson2/JSONSchema/json_schema_cn - 支持
Android - 支持
Graal Native-Image
相关文档:
JSONB格式文档:
https://alibaba.github.io/fastjson2/JSONB/jsonb_format_cnFASTJSON v2性能有了很大提升,具体性能数据看这里:
https://alibaba.github.io/fastjson2/benchmark_cn
1. 使用准备
1.1 添加依赖
在fastjson v2中,groupId和1.x不一样,是com.alibaba.fastjson2:
Maven:
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.66</version>
</dependency>Gradle:
dependencies {
implementation 'com.alibaba.fastjson2:fastjson2:2.0.66'
}可以在 maven.org 查看最新可用的版本。
1.2 其他模块
`Fastjson v1`兼容模块
如果原来使用fastjson 1.2.x版本,可以使用兼容包,兼容包不能保证100%兼容,请仔细测试验证,发现问题请及时反馈。
Maven:
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>2.0.66</version>
</dependency>Gradle:
dependencies {
implementation 'com.alibaba:fastjson:2.0.66'
}`Fastjson Kotlin`集成模块
如果项目使用Kotlin,可以使用fastjson-kotlin模块,使用方式上采用kotlin的特性。
Maven:
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-kotlin</artifactId>
<version>2.0.66</version>
</dependency>Gradle:
dependencies {
implementation("com.alibaba.fastjson2:fastjson2-kotlin:2.0.66")
}`Fastjson Extension`扩展模块
如果项目使用SpringFramework等框架,可以使用fastjson-extension模块,使用方式参考 SpringFramework Support。
Maven:
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-extension</artifactId>
<version>2.0.66</version>
</dependency>Gradle:
dependencies {
implementation 'com.alibaba.fastjson2:fastjson2-extension:2.0.66'
}2 简单使用
在fastjson v2中,package和1.x不一样,是com.alibaba.fastjson2。如果你之前用的是fastjson1,大多数情况直接更包名就即可。
2.1 将`JSON`解析为`JSONObject`
Java:
String text = "...";
JSONObject data = JSON.parseObject(text);
byte[] bytes = ...;
JSONObject data = JSON.parseObject(bytes);Kotlin:
import com.alibaba.fastjson2.*
val text = ... // String
val data = text.parseObject()
val bytes = ... // ByteArray
val data = bytes.parseObject() // JSONObject2.2 将`JSON`解析为`JSONArray`
Java:
String text = "...";
JSONArray data = JSON.parseArray(text);Kotlin:
import com.alibaba.fastjson2.*
val text = ... // String
val data = text.parseArray() // JSONArray2.3 将`JSON`解析为`Java`对象
Java:
String text = "...";
User data = JSON.parseObject(text, User.class);Kotlin:
import com.alibaba.fastjson2.*
val text = ... // String
val data = text.to<User>() // User
val data = text.parseObject<User>() // User2.4 将`Java`对象序列化为`JSON`
Java:
Object data = "...";
String text = JSON.toJSONString(data);
byte[] text = JSON.toJSONBytes(data);Kotlin:
import com.alibaba.fastjson2.*
val data = ... // Any
val text = data.toJSONString() // String
val bytes = data.toJSONByteArray() // ByteArray2.5 使用`JSONObject`、`JSONArray`
2.5.1 获取简单属性
String text = "{\"id\": 2,\"name\": \"fastjson2\"}";
JSONObject obj = JSON.parseObject(text);
int id = obj.getIntValue("id");
String name = obj.getString("name");String text = "[2, \"fastjson2\"]";
JSONArray array = JSON.parseArray(text);
int id = array.getIntValue(0);
String name = array.getString(1);2.5.2 读取`JavaBean`
Java:
JSONArray array = ...
JSONObject obj = ...
User user = array.getObject(0, User.class);
User user = obj.getObject("key", User.class);Kotlin:
val array = ... // JSONArray
val obj = ... // JSONObject
val user = array.getObject<User>(0)
val user = obj.getObject<User>("key")2.5.3 转为`JavaBean`
Java:
JSONArray array = ...
JSONObject obj = ...
User user = obj.toJavaObject(User.class);
List<User> users = array.toJavaList(User.class);Kotlin:
val array = ... // JSONArray
val obj = ... // JSONObject
val user = obj.toObject<User>() // User
val users = array.toList<User>() // List<User>2.6 将`JavaBean`对象序列化为`JSON`
Java:
class User {
public int id;
public String name;
}
User user = new User();
user.id = 2;
user.name = "FastJson2";
String text = JSON.toJSONString(user);
byte[] bytes = JSON.toJSONBytes(user);Kotlin:
class User(
var id: Int,
var name: String
)
val user = User()
user.id = 2
user.name = "FastJson2"
val text = user.toJSONString() // String
val bytes = user.toJSONByteArray() // ByteArray序列化结果:
{
"id" : 2,
"name" : "FastJson2"
}3. 进阶使用
3.1 使用`JSONB`
3.1.1 将`JavaBean`对象序列化`JSONB`
User user = ...;
byte[] bytes = JSONB.toBytes(user);
byte[] bytes = JSONB.toBytes(user, JSONWriter.Feature.BeanToArray);3.1.2 将`JSONB`数据解析为`JavaBean`
byte[] bytes = ...
User user = JSONB.parseObject(bytes, User.class);
User user = JSONB.parseObject(bytes, User.class, JSONReader.Feature.SupportBeanArrayMapping);3.2 使用`JSONPath`
3.2.1 使用`JSONPath`读取部分数据
String text = ...;
JSONPath path = JSONPath.of("$.id"); // 缓存起来重复使用能提升性能
JSONReader parser = JSONReader.of(text);
Object result = path.extract(parser);3.2.2 使用`JSONPath`读取部分`byte[]`的数据
byte[] bytes = ...;
JSONPath path = JSONPath.of("$.id"); // 缓存起来重复使用能提升性能
JSONReader parser = JSONReader.of(bytes);
Object result = path.extract(parser);3.2.3 使用`JSONPath`读取部分`byte[]`的数据
byte[] bytes = ...;
JSONPath path = JSONPath.of("$.id"); // 缓存起来重复使用能提升性能
JSONReader parser = JSONReader.ofJSONB(bytes); // 注意这里使用ofJSONB方法
Object result = path.extract(parser);ARCHITECTURE (`docs/ARCHITECTURE.md`)
Fastjson2 Architecture
Overview
Fastjson2 is a high-performance JSON library for Java, designed as the next-generation version of Fastjson. It supports both JSON and JSONB (binary JSON) formats, with deeply optimized parsing and serialization capabilities targeting JDK 8 through 21+.
Project Structure
fastjson2/
├── core/ # Core library (JDK 8+)
├── extension/ # Base extensions (Arrow, ClickHouse, Geo, Retrofit, etc.)
├── extension-jaxrs/ # JAX-RS integration
├── extension-solon/ # Solon framework integration
├── extension-spring5/ # Spring 5 integration (Web MVC, WebFlux, Data Redis, Messaging)
├── extension-spring6/ # Spring 6 integration
├── fastjson1-compatible/ # Fastjson 1.x API compatibility layer
├── kotlin/ # Kotlin extension functions and DSL
├── codegen/ # Compile-time code generation (APT)
├── benchmark/ # JMH performance benchmarks
├── safemode-test/ # SafeMode test suite
├── android-test/ # Android compatibility tests
├── test-jdk17/ # JDK 17 feature tests (Records, sealed classes)
├── test-jdk25/ # JDK 25 feature tests
└── docs/ # DocumentationCore Module Architecture
Component Overview
/* Detailed source-code truncated for AI context efficiency. */1. JSON API Layer
The public-facing API through which users interact with the library:
JSON.java- Main entry point with static methods (parseObject,parseArray,toJSONString,toJSONBytes)JSONObject.java- JSON object (extendsLinkedHashMap<String, Object>, maintains insertion order)JSONArray.java- JSON array (extendsArrayList<Object>)JSONB.java- Binary JSON format supportJSONPath.java- JSONPath query engine with SQL:2016 compatibilityJSONFactory.java- Factory for creating reader/writer instances with thread-local caching
2. Reader Layer (Parsing / Deserialization)
Encoding-specific parsers that convert input to Java objects:
| Class | Input | Optimization |
|---|---|---|
JSONReaderUTF8 |
UTF-8 byte[] |
SIMD via Vector API (JDK 17+) |
JSONReaderUTF16 |
UTF-16 char[] / String |
Compact string optimization (JDK 9+) |
JSONReaderASCII |
ASCII byte[] |
Fast path for ASCII-only content |
JSONReaderJSONB |
JSONB byte[] |
Binary format decoder |
The abstract JSONReader base class defines the parsing contract. JSONFactory selects the appropriate implementation based on input type and JDK version.
3. Writer Layer (Serialization)
Encoding-specific writers that convert Java objects to output:
| Class | Output | Notes |
|---|---|---|
JSONWriterUTF8 |
UTF-8 byte[] |
Default for toJSONBytes() |
JSONWriterUTF16 |
UTF-16 String |
Default for toJSONString() |
JSONWriterJSONB |
JSONB byte[] |
Binary format encoder |
4. Object Mapping Layer
Reader Package (`com.alibaba.fastjson2.reader`)
| Class | Purpose |
|---|---|
ObjectReader<T> |
Interface for type-specific deserialization |
ObjectReaderProvider |
Manages reader instances with concurrent caching |
FieldReader |
Handles individual field deserialization |
ObjectReaderBaseModule |
Base module for reader extensions |
ObjectReaderCreator |
Base factory for creating readers (uses LambdaMetafactory internally for field access) |
ObjectReaderCreatorASM |
ASM bytecode-generated readers (highest performance) |
ObjectReaderAdapter |
Adapter pattern for readers |
Writer Package (`com.alibaba.fastjson2.writer`)
| Class | Purpose |
|---|---|
ObjectWriter<T> |
Interface for type-specific serialization |
ObjectWriterProvider |
Manages writer instances with concurrent caching |
FieldWriter |
Handles individual field serialization |
ObjectWriterBaseModule |
Base module for writer extensions |
ObjectWriterCreator |
Base factory for creating writers |
ObjectWriterCreatorASM |
ASM bytecode-generated writers (highest performance) |
Creator Selection Strategy
FASTJSON 2 selects the optimal ObjectReader/ObjectWriter creator based on the runtime environment:
JDK 8 server → ObjectReaderCreatorASM (best performance)
JDK 17 server → ObjectReaderCreatorASM + Vector API optimizations
Android → ObjectReaderCreator (LambdaMetafactory-based, no ASM on Android)
GraalVM Native → ObjectReaderCreator (reflection-based, no dynamic bytecode)
SafeMode → ObjectReaderCreator (reflection-based)5. JSONPath Layer
Full JSONPath implementation compatible with SQL:2016:
JSONPath- Query compilation and executionJSONPathSegment- Base class for path segmentsJSONPathSegmentIndex- Array index access ($[0],$[-1])JSONPathSegmentName- Object property access ($.name)JSONPathParser- JSONPath expression parserJSONPathFilter- Filter operations ($[?(@.price > 10)])
JSONPath instances are immutable and thread-safe after construction. They should be cached and reused.
6. Annotation Layer (`com.alibaba.fastjson2.annotation`)
| Annotation | Target | Purpose |
|---|---|---|
@JSONField |
Field, Method, Parameter | Field-level config (name, format, features, ordinal) |
@JSONType |
Class, Interface | Class-level config (naming, ignores, features, ordering) |
@JSONCreator |
Constructor, Method | Specify deserialization constructor or factory method |
@JSONCompiler |
Class | Enable compile-time code generation |
7. Filter Layer (`com.alibaba.fastjson2.filter`)
Serialization filters applied during the write phase:
| Filter | Description |
|---|---|
ValueFilter |
Transform property values before output |
NameFilter |
Rename properties before output |
ContextNameFilter |
Context-aware property renaming |
ContextValueFilter |
Context-aware value transformation |
PropertyFilter |
Conditionally include/exclude properties |
PropertyPreFilter |
Pre-serialization property filtering |
AfterFilter |
Append content after object serialization |
BeforeFilter |
Prepend content before object serialization |
LabelFilter |
Label-based selective serialization |
AutoTypeBeforeHandler |
Whitelist-based AutoType control for deserialization |
8. Schema Layer (`com.alibaba.fastjson2.schema`)
JSONSchema- JSON Schema validation (draft support)- Validates
JSONObject, JavaBeans, and raw JSON data - Can be configured via
@JSONField(schema = "...")annotations
Key Design Patterns
Factory Pattern
JSONFactorycreates reader/writer instances with thread-local recyclingObjectReaderCreator/ObjectWriterCreatorcreate type-specific readers/writers
Provider Pattern
ObjectReaderProvidermanages reader instances withConcurrentHashMapcachingObjectWriterProvidermanages writer instances withConcurrentHashMapcaching- First access triggers creation; subsequent accesses retrieve from cache
Strategy Pattern
JSONReaderimplementations for different encodings (UTF-8, UTF-16, ASCII, JSONB)JSONWriterimplementations for different output formatsObjectReaderCreator(base, uses Lambda/reflection) andObjectReaderCreatorASM(bytecode) selected by environment
Visitor Pattern
JSONPathsegment traversal through document structureJSONReadertoken-based parsing
Module Pattern
ObjectReaderModule/ObjectWriterModuleallow extensions to register custom type handlers- Framework integrations (Spring, JAX-RS) use modules to hook into the serialization pipeline
Performance Optimizations
1. ASM Code Generation
- Generates optimized bytecode at runtime for object readers/writers
- Switch-case on field name hash for O(1) field lookup during deserialization
- Eliminates reflection overhead for field access
- Located in
ObjectReaderCreatorASMandObjectWriterCreatorASM
2. Lambda Metafactory
- Uses
LambdaMetafactoryfor method handles on JDK 8+ - Near-native-call performance for getter/setter invocations
- Used by
ObjectReaderCreatorandObjectWriterCreatorfor field access
3. Vector API (JDK 17+)
- SIMD optimizations for bulk character processing in UTF-8/UTF-16 parsers
- Accelerates string scanning, whitespace skipping, and validation
- Located in
JSONReaderUTF8andJSONReaderUTF16
4. String Interning
SymbolTablefor efficient string reuse of field names- Reduces memory allocation and GC pressure during parsing
- Keys are interned on first encounter and reused on subsequent parses
5. Lazy Parsing
- JSONPath supports partial parsing without full document deserialization
- Only the targeted path is parsed; rest of the document is skipped
- Critical for extracting fields from large JSON documents
6. Thread-Local Buffers
JSONFactoryprovides thread-local reader/writer instances- Buffer recycling reduces allocation overhead in high-throughput scenarios
JSONB Binary Format
JSONB is a binary representation of JSON with the following design:
- Compact encoding: Small integers (-16 to 47) require only 1 byte
- Schema-less: No pre-defined schema needed
- Type-rich: Supports all JSON types plus binary data
- Symbol table: Optional key compression for repeated field names
- Multi-encoding: Strings can be stored as UTF-8, UTF-16, ASCII, or GB18030
Format specification: JSONB Format Documentation
Thread Safety
| Component | Thread-Safe? | Notes |
|---|---|---|
JSON static methods |
Yes | Main entry point |
JSONObject / JSONArray |
No | Like HashMap/ArrayList |
JSONReader / JSONWriter |
No | Create per-operation |
ObjectReader / ObjectWriter |
Yes | After initialization |
JSONPath |
Yes | Immutable after construction |
ObjectReaderProvider / ObjectWriterProvider |
Yes | ConcurrentHashMap-based |
JSONFactory |
Yes | Thread-local instances |
Extension Points
1. Module System
ObjectReaderModule- Register custom deserialization modulesObjectWriterModule- Register custom serialization modules- Modules are registered via
JSONFactory.getDefaultObjectReaderProvider().register(module)
2. Custom ObjectReader/ObjectWriter
- Implement
ObjectReader<T>for custom deserialization logic - Implement
ObjectWriter<T>for custom serialization logic - Register via
JSON.register(Class, ObjectReader/ObjectWriter)
3. Filters
- Apply during serialization for value transformation, name mapping, property filtering
- Register per-call via
JSON.toJSONString(obj, filter)or globally
4. MixIn Annotations
- Inject annotations on third-party classes without modifying source
JSON.mixIn(TargetClass.class, MixInClass.class)
5. AutoType Handlers
AutoTypeBeforeHandler- Custom type validation before deserializationJSONReader.autoTypeFilter(...)- Whitelist-based type filtering per call
Module Dependencies
core (JDK 8+)
├── extension (core)
│ ├── extension-spring5 (core, extension)
│ ├── extension-spring6 (core, extension)
│ ├── extension-solon (core, extension)
│ └── extension-jaxrs (core, extension)
├── fastjson1-compatible (core)
├── kotlin (core)
├── codegen (core)
└── benchmark (core)Build System
- Build tool: Maven with multi-module structure
- Java baseline: JDK 8 (core)
- Kotlin: Version 2.1.20
- ASM: Embedded internally in
com.alibaba.fastjson2.internal.asm(for bytecode generation) - Testing: JUnit 5, Kotest (Kotlin module)
- Code style: Checkstyle (
src/checkstyle/fastjson2-checks.xml) - CI: GitHub Actions across JDK 8/11/17/21/25 on Ubuntu/Windows/macOS
Documentation
- Features Reference - All JSONReader/JSONWriter features
- Annotations Guide - @JSONField, @JSONType, @JSONCreator
- JSONB Format - Binary format specification
- JSONPath Guide - JSONPath syntax and examples
- Kotlin Support - Kotlin API extensions
- Spring Integration - Spring Framework setup
- Performance Guide - Tuning tips and best practices
- FAQ - Frequently asked questions
- Benchmarks - Performance data
FAQ Cn (`docs/FAQ_cn.md`)
常见问题
概述
FASTJSON 和 FASTJSON 2 有什么区别?
FASTJSON 2 是对原始 FASTJSON 库的全面重写,面向未来十年设计。主要区别:
- 新包名:
com.alibaba.fastjson2(v1 为com.alibaba.fastjson) - 更好的性能: 所有操作均有显著提升
- 更安全: AutoType 默认关闭,无硬编码白名单
- 现代 Java: JDK 11/17/21 优化,Record 支持,Vector API
- 二进制格式: 原生 JSONB 支持
- JSON Schema: 内置校验功能
FASTJSON 2 可以和 FASTJSON 1.x 共存吗?
可以。由于使用不同的包名(com.alibaba.fastjson2 vs com.alibaba.fastjson),两者可以在同一项目中共存。但使用兼容模块(com.alibaba:fastjson:2.x)时会与 FASTJSON 1.x 冲突,因为它们共享相同的包名。
支持哪些 Java 版本?
- 核心库: Java 8+
- 完整功能集: Java 11+(compact string 优化)
- Vector API 优化: Java 17+
- Android: Android 8+(API level 26+)
FASTJSON 2 支持 GraalVM Native Image 吗?
支持。FASTJSON 2 兼容 GraalVM Native Image。注意在 native image 中 ASM 代码生成不可用,将使用基于反射或 lambda 的创建器。
解析与反序列化
如何解析结构未知的 JSON?
// 解析为 JSONObject(JSON 对象)
JSONObject obj = JSON.parseObject(jsonString);
// 解析为 JSONArray(JSON 数组)
JSONArray arr = JSON.parseArray(jsonString);
// 解析为通用 Object(自动检测)
Object result = JSON.parse(jsonString);如何解析带泛型的 JSON?
使用 TypeReference 处理复杂泛型:
// List<User>
List<User> users = JSON.parseObject(json, new TypeReference<List<User>>(){});
// Map<String, List<User>>
Map<String, List<User>> map = JSON.parseObject(json,
new TypeReference<Map<String, List<User>>>(){});如何处理日期/时间格式?
使用 @JSONField(format = "...") 或全局配置:
// 字段级别
public class Event {
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
public Date eventTime;
}
// 全局配置
JSON.configReaderDateFormat("yyyy-MM-dd");
// 每次调用
User user = JSON.parseObject(json, User.class, "yyyy-MM-dd");如何进行大小写不敏感的字段匹配?
启用 SupportSmartMatch 可自动处理 camelCase、PascalCase、snake_case 和 kebab-case:
User user = JSON.parseObject(json, User.class, JSONReader.Feature.SupportSmartMatch);注意:智能匹配在 FASTJSON 2 中默认关闭(v1 中默认开启)。
如何使用 BigDecimal 处理浮点数?
JSONObject obj = JSON.parseObject(json,
JSONReader.Feature.UseBigDecimalForFloats,
JSONReader.Feature.UseBigDecimalForDoubles);如何在解析时去除字符串空格?
User user = JSON.parseObject(json, User.class, JSONReader.Feature.TrimString);序列化
如何在 JSON 输出中包含 null 字段?
String json = JSON.toJSONString(user, JSONWriter.Feature.WriteNulls);针对特定 null 值的处理策略:
// null String → ""
JSONWriter.Feature.WriteNullStringAsEmpty
// null List → []
JSONWriter.Feature.WriteNullListAsEmpty
// null Number → 0
JSONWriter.Feature.WriteNullNumberAsZero
// null Boolean → false
JSONWriter.Feature.WriteNullBooleanAsFalse如何格式化输出 JSON?
String json = JSON.toJSONString(user, JSONWriter.Feature.PrettyFormat);如何处理 JavaScript 中的大 Long 值?
JavaScript 无法处理超过 Number.MAX_SAFE_INTEGER(2^53 - 1)的 Java long 值。使用 BrowserCompatible 或 WriteLongAsString:
// 自动检测并将大数字转为字符串
String json = JSON.toJSONString(user, JSONWriter.Feature.BrowserCompatible);
// 始终将 Long 序列化为 String
String json = JSON.toJSONString(user, JSONWriter.Feature.WriteLongAsString);如何按指定顺序序列化字段?
使用 @JSONField(ordinal = N) 或 @JSONType(orders = {...}):
public class User {
@JSONField(ordinal = 1)
public String name;
@JSONField(ordinal = 2)
public int age;
}
// 或在类级别
@JSONType(orders = {"name", "age", "email"})
public class User { ... }如何排除特定字段不参与序列化?
多种方式:
// 基于注解
@JSONField(serialize = false)
public String password;
// 类级别忽略
@JSONType(ignores = {"password", "secretKey"})
public class User { ... }
// 基于过滤器
PropertyFilter filter = (object, name, value) -> !"password".equals(name);
String json = JSON.toJSONString(user, filter);AutoType 与安全
FASTJSON 2 默认安全吗?
是的。与 FASTJSON 1.x 不同,FASTJSON 2 默认禁用 AutoType。包含 @type 字段的 JSON 数据将被忽略,除非显式启用 AutoType。
如何安全地启用 AutoType?
使用 AutoTypeFilter 配合小范围白名单,而不是启用全局 AutoType:
// 推荐:使用范围有限的过滤器和白名单
Filter autoTypeFilter = JSONReader.autoTypeFilter(
"com.mycompany.model" // 仅允许此包下的类
);
Object result = JSON.parseObject(json, Object.class, autoTypeFilter);如果必须启用全局 AutoType(不推荐用于面向互联网的服务):
Object result = JSON.parseObject(json, Object.class, JSONReader.Feature.SupportAutoType);什么是 SafeMode?
SafeMode 完全禁用 AutoType,即使在代码中显式配置也无效。通过 JVM 参数启用:
-Dfastjson2.parser.safeMode=true性能
如何获得最佳解析性能?
- 尽量使用 byte[] 输入 -
JSON.parseObject(bytes, Type.class)可避免 String 转换开销。 - 复用 JSONPath 实例 -
JSONPath.of("$.id")是线程安全的,可缓存重复使用。 - 使用部分解析 - 对于大型文档,使用 JSONPath 仅提取需要的数据。
- 使用 JSONB - 内部服务通信时,JSONB 比文本 JSON 快得多。
- 避免不必要的 Feature - 每个启用的 Feature 会增加少量开销。
如何获得最佳序列化性能?
- 使用 byte[] 输出 -
JSON.toJSONBytes(obj)在大多数场景下比JSON.toJSONString(obj)更快。 - 使用 BeanToArray -
JSONWriter.Feature.BeanToArray产生更小的输出且序列化更快。 - 使用 JSONB - 对于二进制协议,JSONB 性能显著更优。
FASTJSON 2 与 Jackson 和 Gson 相比如何?
FASTJSON 2 在基准测试中始终优于 Jackson 和 Gson。详细数据请参阅 fastjson_benchmark。
Spring 集成
如何在 Spring Boot 中用 FASTJSON 2 替换 Jackson?
添加扩展依赖并配置消息转换器。详见完整的 Spring 集成指南。
Spring 6.x 快速配置:
@Configuration
public class JsonConfig extends WebMvcConfigurationSupport {
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
converters.add(0, converter);
}
}如何在 Spring Data Redis 中使用 FASTJSON 2?
使用 GenericFastJsonRedisSerializer:
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(factory);
template.setDefaultSerializer(new GenericFastJsonRedisSerializer());
return template;
}从 Fastjson 1.x 迁移
最简单的迁移方式是什么?
使用兼容包直接替换:
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>2.0.66</version>
</dependency>这提供与 v1 相同的包名(com.alibaba.fastjson),底层使用 FASTJSON 2 引擎。
`ParserConfig.getGlobalInstance().addAccept()` 如何替换?
在 FASTJSON 2 中,使用 ObjectReaderProvider:
JSONFactory.getDefaultObjectReaderProvider().addAutoTypeAccept("com.mycompany.xxx");`ObjectSerializer` 和 `ObjectDeserializer` 的替代方案是什么?
| Fastjson 1.x | Fastjson 2.x |
|---|---|
ObjectSerializer |
ObjectWriter |
ObjectDeserializer |
ObjectReader |
SerializerFeature |
JSONWriter.Feature |
Feature(解析器) |
JSONReader.Feature |
完整的 API 映射表请参阅 升级指南。
故障排查
遇到 `com.alibaba.fastjson2.JSONException`
常见原因:
- JSON 格式错误 - 使用 JSON 格式检查工具验证您的 JSON。
- 类型不匹配 - JSON 结构与目标 Java 类型不匹配。
- 缺少默认构造函数 - 目标类需要无参构造函数(或使用
@JSONCreator)。 - Enum 不匹配 - 启用
ErrorOnEnumNotMatch获取详细错误信息。
字段未被序列化
请检查:
- 字段必须是
public或有 public getter 方法(除非使用FieldBasedFeature)。 transient字段默认被跳过。- 检查是否应用了
@JSONField(serialize = false)或@JSONType(ignores = ...)。
字段未被反序列化
请检查:
- JSON 键名必须与 Java 字段名匹配(或使用
@JSONField(name = "...")进行映射)。 - 如果 JSON 使用不同的命名规范,启用
SupportSmartMatch。 - 字段必须是
public或有 public setter 方法(除非使用FieldBasedFeature)。
遇到 `ClassNotFoundException` 或 AutoType 错误
FASTJSON 2 默认禁用 AutoType。如果您的 JSON 包含 @type 字段:
- 使用
AutoTypeFilter配合窄范围白名单针对特定类。 - 或启用
SupportAutoType(不推荐用于不可信输入)。 - 不要在面向互联网的服务中使用 AutoType。
FAQ En (`docs/FAQ_en.md`)
Frequently Asked Questions
General
What is the difference between FASTJSON and FASTJSON 2?
FASTJSON 2 is a complete rewrite of the original FASTJSON library, designed for the next decade. Key differences:
- New package:
com.alibaba.fastjson2(v1 wascom.alibaba.fastjson) - Better performance: Significant improvements across all operations
- More secure: AutoType disabled by default, no hardcoded whitelist
- Modern Java: JDK 11/17/21 optimizations, Record support, Vector API
- Binary format: Native JSONB support
- JSON Schema: Built-in validation
Can FASTJSON 2 coexist with FASTJSON 1.x?
Yes. Because they use different package names (com.alibaba.fastjson2 vs com.alibaba.fastjson), both can exist in the same project. However, using the compatibility module (com.alibaba:fastjson:2.x) will conflict with FASTJSON 1.x since they share the same package.
What Java versions are supported?
- Core library: Java 8+
- Full feature set: Java 11+ (compact string optimizations)
- Vector API optimizations: Java 17+
- Android: Android 8+ (API level 26+)
Does FASTJSON 2 support GraalVM Native Image?
Yes. FASTJSON 2 is compatible with GraalVM Native Image. Note that ASM-based code generation is not available in native images, so the reflection-based or lambda-based creator will be used instead.
Parsing & Deserialization
How do I parse JSON with unknown structure?
// Parse as JSONObject (for JSON objects)
JSONObject obj = JSON.parseObject(jsonString);
// Parse as JSONArray (for JSON arrays)
JSONArray arr = JSON.parseArray(jsonString);
// Parse as generic Object (auto-detect)
Object result = JSON.parse(jsonString);How do I parse JSON with generic types?
Use TypeReference for complex generic types:
// List<User>
List<User> users = JSON.parseObject(json, new TypeReference<List<User>>(){});
// Map<String, List<User>>
Map<String, List<User>> map = JSON.parseObject(json,
new TypeReference<Map<String, List<User>>>(){});How do I handle date/time formats?
Use @JSONField(format = "...") or global configuration:
// Per-field
public class Event {
@JSONField(format = "yyyy-MM-dd HH:mm:ss")
public Date eventTime;
}
// Global
JSON.configReaderDateFormat("yyyy-MM-dd");
// Per-call
User user = JSON.parseObject(json, User.class, "yyyy-MM-dd");How do I handle case-insensitive field matching?
Enable SupportSmartMatch to automatically handle camelCase, PascalCase, snake_case, and kebab-case:
User user = JSON.parseObject(json, User.class, JSONReader.Feature.SupportSmartMatch);Note: Smart matching is off by default in FASTJSON 2 (it was on by default in v1).
How do I use BigDecimal for floating-point numbers?
JSONObject obj = JSON.parseObject(json,
JSONReader.Feature.UseBigDecimalForFloats,
JSONReader.Feature.UseBigDecimalForDoubles);How do I trim string values during parsing?
User user = JSON.parseObject(json, User.class, JSONReader.Feature.TrimString);Serialization
How do I include null fields in JSON output?
String json = JSON.toJSONString(user, JSONWriter.Feature.WriteNulls);For specific null handling strategies:
// null String → ""
JSONWriter.Feature.WriteNullStringAsEmpty
// null List → []
JSONWriter.Feature.WriteNullListAsEmpty
// null Number → 0
JSONWriter.Feature.WriteNullNumberAsZero
// null Boolean → false
JSONWriter.Feature.WriteNullBooleanAsFalseHow do I pretty-print JSON?
String json = JSON.toJSONString(user, JSONWriter.Feature.PrettyFormat);How do I handle large Long values for JavaScript compatibility?
JavaScript cannot handle Java long values beyond Number.MAX_SAFE_INTEGER (2^53 - 1). Use BrowserCompatible or WriteLongAsString:
// Auto-detect and convert large numbers to strings
String json = JSON.toJSONString(user, JSONWriter.Feature.BrowserCompatible);
// Always serialize Long as String
String json = JSON.toJSONString(user, JSONWriter.Feature.WriteLongAsString);How do I serialize fields in a specific order?
Use @JSONField(ordinal = N) or @JSONType(orders = {...}):
public class User {
@JSONField(ordinal = 1)
public String name;
@JSONField(ordinal = 2)
public int age;
}
// or at class level
@JSONType(orders = {"name", "age", "email"})
public class User { ... }How do I exclude specific fields from serialization?
Multiple approaches:
// Annotation-based
@JSONField(serialize = false)
public String password;
// Class-level ignore
@JSONType(ignores = {"password", "secretKey"})
public class User { ... }
// Filter-based
PropertyFilter filter = (object, name, value) -> !"password".equals(name);
String json = JSON.toJSONString(user, filter);AutoType & Security
Is FASTJSON 2 secure by default?
Yes. Unlike FASTJSON 1.x, FASTJSON 2 disables AutoType by default. JSON data containing @type fields will be ignored unless you explicitly enable AutoType.
How do I enable AutoType safely?
Use AutoTypeFilter with a narrow whitelist instead of enabling global AutoType:
// Preferred: scoped filter with narrow whitelist
Filter autoTypeFilter = JSONReader.autoTypeFilter(
"com.mycompany.model" // Only allow classes in this package
);
Object result = JSON.parseObject(json, Object.class, autoTypeFilter);If you must enable global AutoType (not recommended for internet-facing services):
Object result = JSON.parseObject(json, Object.class, JSONReader.Feature.SupportAutoType);What is SafeMode?
SafeMode completely disables AutoType, even if explicitly configured in the code. Enable it with a JVM parameter:
-Dfastjson2.parser.safeMode=truePerformance
How do I get the best parsing performance?
- Use byte[] input when possible -
JSON.parseObject(bytes, Type.class)avoids String conversion overhead. - Reuse JSONPath instances -
JSONPath.of("$.id")is cacheable and thread-safe. - Use partial parsing - For large documents, use JSONPath to extract only what you need.
- Use JSONB - For internal service communication, JSONB is significantly faster than text JSON.
- Avoid unnecessary features - Each enabled feature adds a small overhead.
How do I get the best serialization performance?
- Use byte[] output -
JSON.toJSONBytes(obj)is faster thanJSON.toJSONString(obj)for most use cases. - Use BeanToArray -
JSONWriter.Feature.BeanToArrayproduces smaller output and is faster to serialize. - Use JSONB - For binary protocols, JSONB is significantly faster.
How does FASTJSON 2 compare to Jackson and Gson?
FASTJSON 2 consistently outperforms Jackson and Gson in benchmarks. See the detailed benchmark data at fastjson_benchmark.
Spring Integration
How do I replace Jackson with FASTJSON 2 in Spring Boot?
Add the extension dependency and configure the message converter. See the full Spring Integration Guide.
Quick setup for Spring 6.x:
@Configuration
public class JsonConfig extends WebMvcConfigurationSupport {
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
converters.add(0, converter);
}
}How do I use FASTJSON 2 with Spring Data Redis?
Use GenericFastJsonRedisSerializer:
@Bean
public RedisTemplate<String, Object> redisTemplate(RedisConnectionFactory factory) {
RedisTemplate<String, Object> template = new RedisTemplate<>();
template.setConnectionFactory(factory);
template.setDefaultSerializer(new GenericFastJsonRedisSerializer());
return template;
}Migration from Fastjson 1.x
What is the easiest way to migrate?
Use the compatibility package as a drop-in replacement:
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>2.0.66</version>
</dependency>This provides the same package name (com.alibaba.fastjson) with FASTJSON 2's engine underneath.
What changed with `ParserConfig.getGlobalInstance().addAccept()`?
In FASTJSON 2, use ObjectReaderProvider:
JSONFactory.getDefaultObjectReaderProvider().addAutoTypeAccept("com.mycompany.xxx");What replaces `ObjectSerializer` and `ObjectDeserializer`?
| Fastjson 1.x | Fastjson 2.x |
|---|---|
ObjectSerializer |
ObjectWriter |
ObjectDeserializer |
ObjectReader |
SerializerFeature |
JSONWriter.Feature |
Feature (parser) |
JSONReader.Feature |
See the full Migration Guide for the complete API mapping table.
Troubleshooting
I'm getting `com.alibaba.fastjson2.JSONException`
Common causes:
- Malformed JSON - Validate your JSON with a linter.
- Type mismatch - The JSON structure doesn't match the target Java type.
- Missing default constructor - The target class needs a no-arg constructor (or use
@JSONCreator). - Enum mismatch - Enable
ErrorOnEnumNotMatchto get detailed error messages.
Fields are not being serialized
Check for:
- Fields must be
publicor have public getter methods (unless usingFieldBasedfeature). transientfields are skipped by default.- Check if
@JSONField(serialize = false)or@JSONType(ignores = ...)is applied.
Fields are not being deserialized
Check for:
- JSON key names must match Java field names (or use
@JSONField(name = "...")to map). - Enable
SupportSmartMatchif the JSON uses a different naming convention. - Fields must be
publicor have public setter methods (unless usingFieldBasedfeature).
Getting `ClassNotFoundException` or `AutoType` errors
FASTJSON 2 disables AutoType by default. If your JSON contains @type fields:
- Use
AutoTypeFilterwith a narrow whitelist for specific classes. - Or enable
SupportAutoType(not recommended for untrusted input). - Do not use AutoType in internet-facing services.
Annotations Cn (`docs/annotations_cn.md`)
FASTJSON2提供的Annotations
1. JSONField
JSONField是作用在Field、Method、Parameter上的Annotation,可以用来指定序列化字段的顺序、名字、格式、是否忽略、配置JSONReader/JSONWriter的Features等。
1.1 定制序列化和反序列化时的属性名
可以通过JSONField.name来配置序列化输出的字段名和反序列化是映射的字段名。
- 配置在public field上
public class A {
@JSONField(name = "ID")
public int id;
}- 配置在public getter/setter method上
public class A {
private int id;
@JSONField(name = "ID")
public int getId() {return id;}
@JSONField(name = "ID")
public void setId(int value) {this.id = id;}
}1.2 配置字段输出和反序列化的格式
针对Date类型的字段,经常需要用定制的日期格式进行序列化和反序列化,可以通过JSONField.format来配置自定义日期格式。
public class VO {
// 配置date序列化和反序列使用yyyyMMdd日期格式
@JSONField(format = "yyyyMMdd")
public Date date;
}1.3 序列化/反序列化时忽略字段
可以通过JSONField.serialize配置该字段是否要序列化,通过JSONField.deserialize配置该字段是否需要反序列化。
- 配置序列化时忽略特定字段
public class VO {
@JSONField(serialize = false)
public Date date;
}- 配置反序列化忽略特定字段
public class VO {
@JSONField(deserialize = false)
public Date date;
}1.4 配置字段的序列化输出的的顺序
可以通过JSONField.ordinal来配置序列化时输出的顺序。
public static class VO {
@JSONField(ordinal = 1)
public String type;
@JSONField(ordinal = 2)
public String templateId;
}1.5 配置序列化Features
可以通过JSONField.serializeFeatures来指定序列化的Feature。更多配置Features参考 https://alibaba.github.io/fastjson2/features_cn 。
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONWriter.Feature;
import org.junit.jupiter.api.Test;
@Test
public void test() {
Bean bean = new Bean();
bean.id = 100;
assertEquals("{\"id\":\"100\"}", JSON.toJSONString(bean));
}
public static class Bean {
@JSONField(serializeFeatures = Feature.WriteNonStringValueAsString)
public int id;
}1.6 通过JSONField(value = true)配置JavaBean序列化字段和反序列化构造方式
将@JSONField(value = true)配置在其中一个字段上,序列化时,会将对象序列化时按照该字段的值输出。将@JSONField(value = true)配置在构造函数参数上,而且该构造函数只有1个参数,就会按照这个参数来构造对象
比如:
public static class Bean2 {
private final int code;
public Bean2(@JSONField(value = true) int code) {
this.code = code;
}
@JSONField (value = true)
public int getCode() {
return code;
}
}
@Test
public void test2() {
Bean2 bean = new Bean2(101);
String str = JSON.toJSONString(bean);
assertEquals("101", str);
Bean2 bean1 = JSON.parseObject(str, Bean2.class);
assertEquals(bean.code, bean1.code);
}1.7 通过JSONField(value = true)配置Enum基于其中一个字段序列化和反序列化
将@JSONField(value = true)配置在enum字段上,序列化和序列化都会基于这个字段来进行,比如:
public enum Type {
X(101, "Big"),
M(102, "Medium"),
S(103, "Small");
private final int code;
private final String name;
Type(int code, String name) {
this.code = code;
this.name = name;
}
@JSONField(value = true)
public int getCode() {
return code;
}
public String getName() {
return name;
}
}
public class Bean1 {
public Type type;
}
@Test
public void test1() {
Bean1 bean = new Bean1();
bean.type = Type.M;
String str = JSON.toJSONString(bean);
assertEquals("{\"type\":102}", str);
Bean1 bean1 = JSON.parseObject(str, Bean1.class);
assertEquals(bean.type, bean1.type);
}1.8 配置序列化时不忽略transient属性
从2.0.61版本开始,将@JSONField(skipTransient = false)配置在transient字段或@java.beans.Transient修饰的getter方法上,可以强制序列化transient属性。
public class Bean1 {
@JSONField(skipTransient = false)
public transient int id;
}
public class Bean2 {
private int id;
@JSONField(skipTransient = false)
@java.beans.Transient
public int getId() {
return id;
}
}2. @JSONType
JSONType是配置在类/接口上的注解,可以配置改类的所有字段的NamingStrategy、序列化和反序列化忽略的字段、JSONReader/JSONWriter的Features等。
| JSONType注解支持方法 | 简介 |
|---|---|
| ignores | 序列化时忽略某些字段 |
| alphabetic | 配置序列化时保持原生类字段顺序 |
| serializeFeatures | 配置序列化时JSONWriter的Features |
| deserializeFeatures | 配置反序列化时JSONReader的Features |
| orders | 配置序列化时的字段顺序 |
| naming | 配置字段名的NamingStrategy,详细内容请参考PropertyNamingStrategy枚举类 |
| serializer | 自定义序列化行为 |
| deserializer | 自定义反序列化行为 |
| serializeFilters | 通过自定义列化Filters控制序列化行为 |
2.1 配置序列化和反序列化时忽略某些字段
在下面的例子中,序列化输出只包括id1,忽略id2和id3。
@JSONType(ignores = {"id2", "id3"})
public static class Bean {
public int getId() {
return 101;
}
public int getId2() {
return 102;
}
public int getId3() {
return 103;
}
}2.2 配置序列化时保持原生类字段顺序
从2.0.13版本开始,您可以通过@JSONType(alphabetic = false)配置序列化时保持原生类字段顺序。
@Slf4j
public class JSONTypeAlphabetic {
@JSONType(alphabetic = false)
public static class Bean {
public int f3;
public int f1;
public int f2;
public int f0;
}
@Test
public void test() {
Bean bean = new Bean();
bean.f0 = 101;
bean.f1 = 102;
bean.f2 = 103;
bean.f3 = 104;
log.info(JSON.toJSONString(bean));
//{"f3":104,"f1":102,"f2":103,"f0":101}
}
}2.3 配置序列化时的`JSONReader`/`JSONWriter`的`Features`
您可以通过@JSONType(serializeFeatures= ...)或@JSONType(deserializeFeatures = ...)注解配置序列化和反序列时JSONWriter/JSONReader的Features。
更多Features配置请参考 Features文档 。
@Slf4j
public class JSONTypeFeatures {
// 反序列化时对字符串进行trim
// 序列化时输出为null的字段
@JSONType(deserializeFeatures = JSONReader.Feature.TrimString, serializeFeatures = JSONWriter.Feature.WriteNulls)
public static class OrdersBean {
public String filed1;
public String filed2;
}
@Test
public void test() {
OrdersBean bean = new OrdersBean();
bean.filed1 = "fastjson2";
log.info(JSON.toJSONString(bean));
//{"filed1":"fastjson2","filed2":null}
String json="{\"filed1\":\" fastjson2 \",\"filed2\":\"2\"}";
OrdersBean bean2 = JSON.parseObject(json, OrdersBean.class);
log.info(bean2.filed1);
//fastjson2
}
}2.4 配置序列化时字段顺序
您可以通过@JSONType(orders = {"filed1", "filed2"})注解指定序列化时的字段顺序。
@Slf4j
public class JSONTypeOrders {
@JSONType(orders = {"filed4", "filed3", "filed2", "filed1"})
public static class OrdersBean {
public String filed1;
public String filed2;
public String filed3;
public String filed4;
}
@Test
public void test() {
OrdersBean bean = new OrdersBean();
bean.filed1 = "1";
bean.filed2 = "2";
bean.filed3 = "3";
bean.filed4 = "4";
log.info(JSON.toJSONString(bean));
//{"filed4":"4","filed3":"3","filed2":"2","filed1":"1"}
}
}2.5 配置序列化时不忽略transient属性
从2.0.61版本开始,您可以通过@JSONType(skipTransient = false)配置强制序列化transient属性。
@JSONType(skipTransient = false)
public class Bean1 {
public transient int id;
}
@JSONType(skipTransient = false)
public class Bean2 {
private int id;
@java.beans.Transient
public int getId() {
return id;
}
}3. 基于mixin机制注入Annotation
当你需要定制化序列化一些LIB里面的类,你无法修改这些类的代码,你可以使用FASTJSON2的Minxin功能注入Annotation。
具体使用介绍参考这里: https://alibaba.github.io/fastjson2/mixin_cn
Annotations En (`docs/annotations_en.md`)
Annotations provided by FASTJSON2
1. JSONField
JSONField is an Annotation that acts on Field, Method, and Parameter. It can be used to specify the order, name, format, and whether to ignore serialized fields, configure JSONReader/JSONWriter Features, etc.
1.1 Attribute names when customizing serialization and deserialization
The field name of the serialized output and the mapped field name of the deserialization can be configured through JSONField.name .
- Configured on the public field
public class A {
@JSONField(name = "ID")
public int id;
}- Configured on public getter/setter methods
public class A {
private int id;
@JSONField(name = "ID")
public int getId() {return id;}
@JSONField(name = "ID")
public void setId(int value) {this.id = id;}
}1.2 Configure the format of field output and deserialization
For fields of Date type, it is often necessary to use a custom date format for serialization and deserialization, and the custom date format can be configured through JSONField.format.
public class VO {
// Configure date serialization and deserialization to use the yyyyMMdd date format
@JSONField(format = "yyyyMMdd")
public Date date;
}1.3 Ignore fields when serializing and deserializing
You can configure whether the field needs to be serialized through JSONField.serialize, and whether the field needs to be deserialized through JSONField.deserialize.
- Ignore specific fields when configuring serialization
public class VO {
@JSONField(serialize = false)
public Date date;
}- Ignore specific fields when configuring deserialization
public class VO {
@JSONField(deserialize = false)
public Date date;
}1.4 The order of the serialized output of configuration fields
The order of output during serialization can be configured through JSONField.ordinal.
public static class VO {
@JSONField(ordinal = 1)
public String type;
@JSONField(ordinal = 2)
public String templateId;
}1.5 Configure Serialize Features
The serialized Feature can be specified through JSONField.serializeFeatures. More configuration features reference https://alibaba.github.io/fastjson2/features_cn 。
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONWriter.Feature;
import org.junit.jupiter.api.Test;
@Test
public void test() {
Bean bean = new Bean();
bean.id = 100;
assertEquals("{\"id\":\"100\"}", JSON.toJSONString(bean));
}
public static class Bean {
@JSONField(serializeFeatures = Feature.WriteNonStringValueAsString)
public int id;
}1.6 Configure JavaBean serialization fields and deserialization construction methods through JSONField (value = true)
Configure @JSONField(value = true) on one of the fields. When serializing, the object will be serialized and output according to the value of the field. Configure @JSONField(value = true) on the constructor parameter, and the constructor has only one parameter, and the object will be constructed according to this parameter
For example :
public static class Bean2 {
private final int code;
public Bean2(@JSONField(value = true) int code) {
this.code = code;
}
@JSONField (value = true)
public int getCode() {
return code;
}
}
@Test
public void test2() {
Bean2 bean = new Bean2(101);
String str = JSON.toJSONString(bean);
assertEquals("101", str);
Bean2 bean1 = JSON.parseObject(str, Bean2.class);
assertEquals(bean.code, bean1.code);
}1.7 Configure Enum to serialize and deserialize based on one of the fields through JSONField(value = true)
Configure @JSONField(value = true) on the enum field, serialization and serialization will be based on this field
For example :
public enum Type {
X(101, "Big"),
M(102, "Medium"),
S(103, "Small");
private final int code;
private final String name;
Type(int code, String name) {
this.code = code;
this.name = name;
}
@JSONField(value = true)
public int getCode() {
return code;
}
public String getName() {
return name;
}
}
public class Bean1 {
public Type type;
}
@Test
public void test1() {
Bean1 bean = new Bean1();
bean.type = Type.M;
String str = JSON.toJSONString(bean);
assertEquals("{\"type\":102}", str);
Bean1 bean1 = JSON.parseObject(str, Bean1.class);
assertEquals(bean.type, bean1.type);
}1.8 Don't ignore transient fields when serializing
Starting from version 2.0.61, configure @JSONField(skipTransient = false) on transient fields or getter methods annotated with @java.beans.Transient. This can force serialization of transient fields.
public class Bean1 {
@JSONField(skipTransient = false)
public transient int id;
}
public class Bean2 {
private int id;
@JSONField(skipTransient = false)
@java.beans.Transient
public int getId() {
return id;
}
}2. @JSONType
JSONType is an Annotation configured on Class/Interface, which can configure the NamingStrategy of all fields of the modified class, fields ignored by serialization and deserialization, Features of JSONReader/JSONWriter, etc.
| JSONType Annotation Supported | Introduction |
|---|---|
| ignores | Some fields are ignored when serialize |
| alphabetic | Maintain native class field order when configuring serialize |
| serializeFeatures | Features of JSONWriter when configuring serialize |
| deserializeFeatures | Features of JSONReader when configuring deserialize |
| orders | Field order when configuring serialize |
| naming | Configure the NamingStrategy of the field name, for details, please refer to the PropertyNamingStrategy enumeration class |
| serializer | custom serializer behavior |
| deserializer | custom deserializer behavior |
| serializeFilters | Control serializer behavior through custom columnization Filters |
2.1 Configure ignored fields for serialize and deserialize
In the example below, the serialized output only includes id1, ignoring id2 and id3.
@JSONType(ignores = {"id2", "id3"})
public static class Bean {
public int getId() {
return 101;
}
public int getId2() {
return 102;
}
public int getId3() {
return 103;
}
}2.2 Maintain native class field order when configuring serialize
Starting from version 2.0.13, you can use @JSONType(alphabetic = false) to configure serialization to maintain the order of native class fields.
@Slf4j
public class JSONTypeAlphabetic {
@JSONType(alphabetic = false)
public static class Bean {
public int f3;
public int f1;
public int f2;
public int f0;
}
@Test
public void test() {
Bean bean = new Bean();
bean.f0 = 101;
bean.f1 = 102;
bean.f2 = 103;
bean.f3 = 104;
log.info(JSON.toJSONString(bean));
//{"f3":104,"f1":102,"f2":103,"f0":101}
}
}2.3 `Features` of `JSONReader`/`JSONWriter` when configuring serialize and deserialize
You can configure Features of JSONWriter/JSONReader during serialize and deserialize through @JSONType(serializeFeatures= ...) or @JSONType(deserializeFeatures = ...) annotations.
More Features Configuration please refer to Features Documentation 。
@Slf4j
public class JSONTypeFeatures {
// Trim the string when serialize
// Fields that output null when deserialize
@JSONType(deserializeFeatures = JSONReader.Feature.TrimString, serializeFeatures = JSONWriter.Feature.WriteNulls)
public static class OrdersBean {
public String filed1;
public String filed2;
}
@Test
public void test() {
OrdersBean bean = new OrdersBean();
bean.filed1 = "fastjson2";
log.info(JSON.toJSONString(bean));
//{"filed1":"fastjson2","filed2":null}
String json="{\"filed1\":\" fastjson2 \",\"filed2\":\"2\"}";
OrdersBean bean2 = JSON.parseObject(json, OrdersBean.class);
log.info(bean2.filed1);
//fastjson2
}
}2.4 Field order when configuring serialize
You can use @JSONType(orders = {"filed1", "filed2"}) annotation to specify the field order during serialize.
@Slf4j
public class JSONTypeOrders {
@JSONType(orders = {"filed4", "filed3", "filed2", "filed1"})
public static class OrdersBean {
public String filed1;
public String filed2;
public String filed3;
public String filed4;
}
@Test
public void test() {
OrdersBean bean = new OrdersBean();
bean.filed1 = "1";
bean.filed2 = "2";
bean.filed3 = "3";
bean.filed4 = "4";
log.info(JSON.toJSONString(bean));
//{"filed4":"4","filed3":"3","filed2":"2","filed1":"1"}
}
}2.5 Don't ignore transient fields when serializing
Starting from version 2.0.61, you can configure the mandatory serialization of transient properties through @ JSONType (skipTransient=false).
@JSONType(skipTransient = false)
public class Bean1 {
public transient int id;
}
@JSONType(skipTransient = false)
public class Bean2 {
private int id;
@java.beans.Transient
public int getId() {
return id;
}
}3. Inject Annotation based on mixin mechanism
When you need to customize and serialize some classes in LIB, and you cannot modify the code of these classes, you can use the Minxin function of FASTJSON2 to inject Annotation.
For specific usage, refer to here: https://alibaba.github.io/fastjson2/mixin_cn
Autotype Cn (`docs/autotype_cn.md`)
FASTJSON 2 Autotype机制介绍
1. AutoType功能介绍
FASTJSON支持AutoType功能,这个功能会在序列化的JSON字符串中带上类型信息,在反序列化时,不需要传入类型,实现自动类型识别。
2. AutoType安全机制介绍
- 必须显式打开才能使用。和fastjson 1.x不一样,fastjson 1.x为了兼容有一个白名单,在fastjson 2中,没有任何白名单,也不包括任何Exception类的白名单,必须显式打开才能使用。这可以保证缺省配置下是安全的。
- 支持配置safeMode,在safeMode打开后,显式传入AutoType参数也不起作用。
- 显式打开后,会经过内置黑名单过滤。该黑名单能拦截大部分常见风险,这个机制不能保证绝对安全,打开AutoType不应该在暴露在公网的场景下使用。
2.1 accept前缀不覆盖黑名单类型(2.0.63 起)
ClassLoader子类和JDK SQL的DataSource/RowSet实现是反序列化利用链的常见入口,用前缀注册accept不再放行这些类型,必须写全类名才算显式授权。适用于addAutoTypeAccept、-Dfastjson2.autoTypeAccept、JSONReader.autoTypeFilter,以及fastjson 1.x兼容模式的ParserConfig.addAccept。
// 2.0.63 之前:前缀accept会放行 DruidDataSource
// 2.0.63 起:被拒绝
ParserConfig.getGlobalInstance().addAccept("com.alibaba.druid.pool.");
// 确实需要时,写全类名
ParserConfig.getGlobalInstance().addAccept("com.alibaba.druid.pool.DruidDataSource");在此之前,注册了accept前缀的类型比完全没有注册的类型检查更松:同一个类型名在没有accept前缀时会被黑名单拦下,加了前缀反而能加载出来。
3. AutoType功能使用介绍
3.1 序列化时带上类型信息
如果需要序列化时带上类型信息,需要使用JSONWriter.Feature.WriteClassName。比如:
Bean bean = ...;
String jsonString = JSON.toJSONString(bean, JSONWriter.Feature.WriteClassName);很多时候,root对象是可以知道类型的,里面的对象字段是基类或者不确定类型,这个时候不输出root对象的类型信息,可以减少序列化结果的大小,也能提升反序列化的性能。
Bean bean = ...;
String jsonString = JSON.toJSONString(bean, JSONWriter.Feature.WriteClassName, JSONWriter.Feature.NotWriteRootClassName);3.2 反序列化时打开AutoType功能以支持自动类型
Bean bean = (Bean) JSON.parseObject(jsonString, Object.class, JSONReader.Feature.SupportAutoType);4. 配置safeMode
配置SafeMode会完全禁用AutoType功能,如果程序中显式指定类型,AutoType功能也不会生效。
4.1 JVM启动参数配置
-Dfastjson2.parser.safeMode=true5. 使用AutoTypeFilter在不打开AutoTypeSupport时实现自动类型
当打开AutoTypeSupport,虽然内置了一个比较广泛的黑名单,但仍然是不够安全的。下面有一种办法是控制当前调用的AutoType支持范围,避免全局打开,这个更安全。
public class FastJsonRedisSerializer<T> implements RedisSerializer<T> {
static final Filter autoTypeFilter = JSONReader.autoTypeFilter(
// 按需加上需要支持自动类型的类名前缀,范围越小越安全
"org.springframework.security.core.authority.SimpleGrantedAuthority"
);
private Class<T> clazz;
public FastJsonRedisSerializer(Class<T> clazz) {
super();
this.clazz = clazz;
}
@Override
public byte[] serialize(T t) {
if (t == null) {
return new byte[0];
}
return JSON.toJSONBytes(t, JSONWriter.Feature.WriteClassName);
}
@Override
public T deserialize(byte[] bytes) {
if (bytes == null || bytes.length <= 0) {
return null;
}
return JSON.parseObject(bytes, clazz, autoTypeFilter);
}
}Autotype En (`docs/autotype_en.md`)
Introduction to FASTJSON 2 AutoType Mechanism
1. Introduction to the AutoType Feature
FASTJSON supports the AutoType feature, which includes type information in the serialized JSON string. During deserialization, it is not necessary to pass in the type, as it enables automatic type identification.
2. Introduction to the AutoType Security Mechanism
- Must be explicitly enabled for use. Unlike fastjson 1.x, which had a whitelist for compatibility, fastjson 2 has no whitelist at all, not even for Exception classes. It must be explicitly enabled to be used. This ensures that the default configuration is secure.
- Supports
safeModeconfiguration. WhensafeModeis enabled, explicitly passing AutoType parameters will have no effect. - Filtered by a built-in blacklist when explicitly enabled. This blacklist can intercept most common risks, but this mechanism cannot guarantee absolute security. Enabling AutoType should not be done in scenarios exposed to the public internet.
2.1 Accept prefixes do not cover blacklisted types (since 2.0.63)
ClassLoader subclasses and JDK SQL DataSource/RowSet implementations are common deserialization gadget entry points, and registering an accept entry by prefix no longer allows them. Only an accept entry naming the type in full counts as an explicit opt-in. This applies to addAutoTypeAccept, -Dfastjson2.autoTypeAccept, JSONReader.autoTypeFilter, and ParserConfig.addAccept in fastjson 1.x compatibility mode.
// before 2.0.63: the accept prefix allowed DruidDataSource
// since 2.0.63: rejected
ParserConfig.getGlobalInstance().addAccept("com.alibaba.druid.pool.");
// name the type in full where it is genuinely needed
ParserConfig.getGlobalInstance().addAccept("com.alibaba.druid.pool.DruidDataSource");Before this change, a type covered by an accept prefix was checked less strictly than one that was never registered at all: the same type name was stopped by the blacklist without the accept prefix, and loaded successfully with it.
3. How to Use the AutoType Feature
3.1 Including Type Information During Serialization
If you need to include type information during serialization, you need to use JSONWriter.Feature.WriteClassName. For example:
Bean bean = ...;
String jsonString = JSON.toJSONString(bean, JSONWriter.Feature.WriteClassName);Often, the type of the root object is known, while the object fields inside are base classes or of uncertain types. In this case, not outputting the type information for the root object can reduce the size of the serialized result and improve deserialization performance.
Bean bean = ...;
String jsonString = JSON.toJSONString(bean, JSONWriter.Feature.WriteClassName, JSONWriter.Feature.NotWriteRootClassName);3.2 Enabling the AutoType Feature for Automatic Type Support During Deserialization
Bean bean = (Bean) JSON.parseObject(jsonString, Object.class, JSONReader.Feature.SupportAutoType);4. Configuring `safeMode`
Configuring SafeMode will completely disable the AutoType feature. Even if the type is explicitly specified in the program, the AutoType feature will not take effect.
4.1 JVM Startup Parameter Configuration
-Dfastjson2.parser.safeMode=true5. Using AutoTypeFilter for Automatic Types without Enabling `AutoTypeSupport`
When AutoTypeSupport is enabled, although there is a relatively extensive built-in blacklist, it is still not secure enough. A safer approach is to control the scope of AutoType support for the current call, avoiding enabling it globally.
public class FastJsonRedisSerializer<T> implements RedisSerializer<T> {
static final Filter autoTypeFilter = JSONReader.autoTypeFilter(
// Add class name prefixes that need to support auto-typing as needed. The smaller the scope, the safer.
"org.springframework.security.core.authority.SimpleGrantedAuthority"
);
private Class<T> clazz;
public FastJsonRedisSerializer(Class<T> clazz) {
super();
this.clazz = clazz;
}
@Override
public byte[] serialize(T t) {
if (t == null) {
return new byte[0];
}
return JSON.toJSONBytes(t, JSONWriter.Feature.WriteClassName);
}
@Override
public T deserialize(byte[] bytes) {
if (bytes == null || bytes.length <= 0) {
return null;
}
return JSON.parseObject(bytes, clazz, autoTypeFilter);
}
}Benchmark Cn (`docs/benchmark_cn.md`)
1. Eishay测试
create ser deser total size +dfl
json-array/fastjson/databind 30 455 414 869 284 171
protobuf 159 601 319 919 242 152
cbor/jackson+afterburner/databind 29 565 753 1318 398 251
json/fastjson/databind 29 659 707 1366 489 271
json/jackson+afterburner/databind 28 663 837 1500 488 271
cbor/jackson/databind 30 587 1040 1628 398 251
json/jackson/databind 29 697 1099 1796 488 271
json/gson/databind 28 2091 1803 3893 489 268
hessian 29 2062 2619 4681 504 319
java-built-in 29 2815 15730 18545 892 5202. 直接JMH性能测试比较
2.1 测试环境
- MacBook Pro (16-inch, 2021) MacApple M1 Max, 64GB Memory
- ZuluJDK
2.1.1 比较的版本
- Fastjson 2.0.1
- Fastjson 1.2.79
- Jackson 2.12.4
2.1.2 JDK版本
- JDK 8 zulu8.60.0.21-ca-jdk8.0.322-macosx_aarch64
- JDK 11 zulu11.54.25-ca-jdk11.0.14.1-macosx_aarch64
- JDK 17 zulu17.32.13-ca-jdk17.0.2-macosx_aarch64
2.2 Parse性能比较
2.2.1 场景介绍及结论
- EishayParseTreeString场景,将String解析成JSONObject/JSONArray或者HashMap/ArrayList。在这个场景,fastjson2表现出了两倍于fastjson1的性能
- EishayParseString场景,将String反序列化为JavaBean对象,在这个场景fastjson2相对于fastjson1性能提升了30%的性能。
- EishayParseStringPretty,将格式化带空格和换行符缩进的String反序列化为JavaBean对象,fastjson2在3.44倍于fastjson1。这个场景在fastjson1中是弱项,在fastjson2中采用新解析的算法,性能有了非常大提升。
- EishayParseUTF8Bytes,将UTF8格式的byte[]反序列化为JavaBean对象,
2.2.2 MacOS_M1Max_ARM_Zulu_JDK8
/* Detailed source-code truncated for AI context efficiency. */2.2.3 MacOS_M1Max_ARM_Zulu_JDK11
/* Detailed source-code truncated for AI context efficiency. */2.2.4 MacOS_M1Max_ARM_Zulu_JDK17
/* Detailed source-code truncated for AI context efficiency. */2.3 WriteString
2.3.1 场景介绍及结论
- EishayWriteString场景,将JavaBean对象序列化为字符串。这个场景中,fastjson2比fastjson1和jackson分别有164%和85%的性能提升
- EishayWriteUTF8Bytes场景,将JavaBean对象序列化为UTF8格式的byte数组。这个场景中,fastjson2比fastjson1和jackson分别有185%和93%的性能提升
2.3.2 MacOS_M1Max_ARM_Zulu_JDK8
Benchmark Mode Cnt Score Error Units
EishayWriteString.fastjson2 thrpt 5 3076.439 ± 4.692 ops/ms
EishayWriteString.fastjson1 thrpt 5 1162.488 ± 9.076 ops/ms
EishayWriteString.jackson thrpt 5 1664.961 ± 3.204 ops/ms
EishayWriteUTF8Bytes.fastjson2 thrpt 5 2868.597 ± 5.674 ops/ms
EishayWriteUTF8Bytes.fastjson1 thrpt 5 1005.945 ± 3.602 ops/ms
EishayWriteUTF8Bytes.jackson thrpt 5 1481.545 ± 5.302 ops/ms2.3.3 MacOS_M1Max_ARM_Zulu_JDK11
Benchmark Mode Cnt Score Error Units
EishayWriteString.fastjson2 thrpt 5 2816.795 ± 11.322 ops/ms
EishayWriteString.fastjson1 thrpt 5 1063.862 ± 7.016 ops/ms
EishayWriteString.jackson thrpt 5 1617.422 ± 5.465 ops/ms
EishayWriteUTF8Bytes.fastjson2 thrpt 5 3051.648 ± 8.048 ops/ms
EishayWriteUTF8Bytes.fastjson1 thrpt 5 1033.902 ± 11.964 ops/ms
EishayWriteUTF8Bytes.jackson thrpt 5 1381.491 ± 12.199 ops/ms2.3.4 MacOS_M1Max_ARM_Zulu_JDK17
Benchmark Mode Cnt Score Error Units
EishayWriteString.fastjson2 thrpt 5 3064.658 ± 16.216 ops/ms
EishayWriteString.fastjson1 thrpt 5 1250.379 ± 6.057 ops/ms
EishayWriteString.jackson thrpt 5 1682.306 ± 6.945 ops/ms
EishayWriteUTF8Bytes.fastjson2 thrpt 5 2895.860 ± 78.134 ops/ms
EishayWriteUTF8Bytes.fastjson1 thrpt 5 1015.617 ± 11.698 ops/ms
EishayWriteUTF8Bytes.jackson thrpt 5 1599.584 ± 3.278 ops/msBenchmark En (`docs/benchmark_en.md`)
1. Eishay Test
create ser deser total size +dfl
json-array/fastjson/databind 30 455 414 869 284 171
protobuf 159 601 319 919 242 152
cbor/jackson+afterburner/databind 29 565 753 1318 398 251
json/fastjson/databind 29 659 707 1366 489 271
json/jackson+afterburner/databind 28 663 837 1500 488 271
cbor/jackson/databind 30 587 1040 1628 398 251
json/jackson/databind 29 697 1099 1796 488 271
json/gson/databind 28 2091 1803 3893 489 268
hessian 29 2062 2619 4681 504 319
java-built-in 29 2815 15730 18545 892 5202. Direct JMH Performance Comparison
2.1 Test Environment
- MacBook Pro (16-inch, 2021) MacApple M1 Max, 64GB Memory
- ZuluJDK
2.1.1 Versions Compared
- Fastjson 2.0.1
- Fastjson 1.2.79
- Jackson 2.12.4
2.1.2 JDK Versions
- JDK 8 zulu8.60.0.21-ca-jdk8.0.322-macosx_aarch64
- JDK 11 zulu11.54.25-ca-jdk11.0.14.1-macosx_aarch64
- JDK 17 zulu17.32.13-ca-jdk17.0.2-macosx_aarch64
2.2 Parse Performance Comparison
2.2.1 Scenario Introduction and Conclusion
- EishayParseTreeString scenario: Parsing a String into
JSONObject/JSONArrayorHashMap/ArrayList. In this scenario, fastjson2 shows twice the performance of fastjson1. - EishayParseString scenario: Deserializing a String into a JavaBean object. In this scenario, fastjson2 has a 30% performance improvement over fastjson1.
- EishayParseStringPretty: Deserializing a formatted String with spaces, newlines, and indentation into a JavaBean object. fastjson2 is 3.44 times faster than fastjson1. This was a weak point for fastjson1, but with a new parsing algorithm in fastjson2, the performance has been greatly improved.
- EishayParseUTF8Bytes: Deserializing a UTF8-formatted
byte[]into a JavaBean object.
2.2.2 MacOS_M1Max_ARM_Zulu_JDK8
/* Detailed source-code truncated for AI context efficiency. */2.2.3 MacOS_M1Max_ARM_Zulu_JDK11
/* Detailed source-code truncated for AI context efficiency. */2.2.4 MacOS_M1Max_ARM_Zulu_JDK17
/* Detailed source-code truncated for AI context efficiency. */2.3 WriteString
2.3.1 Scenario Introduction and Conclusion
- EishayWriteString scenario: Serializing a JavaBean object into a string. In this scenario, fastjson2 shows performance improvements of 164% and 85% over fastjson1 and jackson, respectively.
- EishayWriteUTF8Bytes scenario: Serializing a JavaBean object into a UTF8-formatted byte array. In this scenario, fastjson2 shows performance improvements of 185% and 93% over fastjson1 and jackson, respectively.
2.3.2 MacOS_M1Max_ARM_Zulu_JDK8
Benchmark Mode Cnt Score Error Units
EishayWriteString.fastjson2 thrpt 5 3076.439 ± 4.692 ops/ms
EishayWriteString.fastjson1 thrpt 5 1162.488 ± 9.076 ops/ms
EishayWriteString.jackson thrpt 5 1664.961 ± 3.204 ops/ms
EishayWriteUTF8Bytes.fastjson2 thrpt 5 2868.597 ± 5.674 ops/ms
EishayWriteUTF8Bytes.fastjson1 thrpt 5 1005.945 ± 3.602 ops/ms
EishayWriteUTF8Bytes.jackson thrpt 5 1481.545 ± 5.302 ops/ms2.3.3 MacOS_M1Max_ARM_Zulu_JDK11
Benchmark Mode Cnt Score Error Units
EishayWriteString.fastjson2 thrpt 5 2816.795 ± 11.322 ops/ms
EishayWriteString.fastjson1 thrpt 5 1063.862 ± 7.016 ops/ms
EishayWriteString.jackson thrpt 5 1617.422 ± 5.465 ops/ms
EishayWriteUTF8Bytes.fastjson2 thrpt 5 3051.648 ± 8.048 ops/ms
EishayWriteUTF8Bytes.fastjson1 thrpt 5 1033.902 ± 11.964 ops/ms
EishayWriteUTF8Bytes.jackson thrpt 5 1381.491 ± 12.199 ops/ms2.3.4 MacOS_M1Max_ARM_Zulu_JDK17
Benchmark Mode Cnt Score Error Units
EishayWriteString.fastjson2 thrpt 5 3064.658 ± 16.216 ops/ms
EishayWriteString.fastjson1 thrpt 5 1250.379 ± 6.057 ops/ms
EishayWriteString.jackson thrpt 5 1682.306 ± 6.945 ops/ms
EishayWriteUTF8Bytes.fastjson2 thrpt 5 2895.860 ± 78.134 ops/ms
EishayWriteUTF8Bytes.fastjson1 thrpt 5 1015.617 ± 11.698 ops/ms
EishayWriteUTF8Bytes.jackson thrpt 5 1599.584 ± 3.278 ops/msCsv Cn (`docs/csv_cn.md`)
CSV (comma-separated values)是一种使用逗号作为分隔符的被广泛使用的数据交换文件格式。
fastjson提供了一个高性能CSV读写支持。
1. 识别行数
分析CSV格式的文件有多少行,如果CSV文件有Header,具体数据行数要减1
File file = ...;
int rowCount = CSVReader.rowCount(file);2. 分析文件内容
File file = ...;
CSVReader parser = CSVReader.of(file);
// 先读取Header第一行
parser.readHeader();
// 对数据进行统计分析
parser.statAll();
// 获取各个列的分析结果
List<StreamReader.ColumnStat> columns = parser.getColumnStats();
// 根据列的统计信息生成建表语句
StringBuilder sql = new StringBuilder();
sql.append("CREATE TABLE ").append(tableName).append(" (\n");
for (int i = 0; i < columns.size(); i++) {
StreamReader.ColumnStat columnStat = columns.get(i);
sql.append('\t')
.append(columnName)
.append(' ')
.append(columnStat.getInferSQLType());
if (i != columns.size() - 1) {
sql.append(',');
}
sql.append("\n");
}
sql.append(");");3. 缺省按照String类型来读取文件
File file = ...;
CSVReader parser = CSVReader.of(file);
// 根据需要,先读取Header第一行,如果没有Header可以忽略
parser.readHeader();
while (true) {
String[] line = parser.readLine();
if (line == null) {
break;
}
// handler line
}4. 指定每列的数据类型来读取文件
File file = ...;
Type[] types = new Type[] {
Integer.class,
Long.class,
String.class ,
Date.class
};
// 构造CSVReader传入各列的类型信息
CSVReader parser = CSVReader.of(file, types);
// 根据需要,先读取Header第一行,如果没有Header可以忽略
parser.readHeader();
while (true) {
Object[] line = parser.readLineValues();
if (line == null) {
break;
}
// 处理数据,每列的值都会和构造CSVReader时传入的types对应
Integer v0 = line[0];
Long v1 = line[1];
String v2 = line[2];
Date v3 = line[3];
}5. 将每行数据读取成一个JavaBean
@Data
class Bean {
long id;
int age;
String name;
Date created;
}
File file = ...;
// 构造CSVReader传入对象类型
CSVReader parser = CSVReader.of(file, Bean.class);
// 根据需要,先读取Header第一行,如果没有Header可以忽略
parser.readHeader();
while (true) {
Bean object = (Bean) parser.readLineObject();
if (object == null) {
break;
}
// 处理数据 ...
}5.1 使用Lambda Consumer来读取JavaBean
File file = ...;
// 构造CSVReader传入对象类型
CSVReader parser = CSVReader.of(file, Bean.class);
// 根据需要,是否要读取Header第一行
boolean readHeader = true;
parser.readLineObjectAll(
readHeader,
e -> {
处理数据 ...
}
);6. 写入CSV格式文件
File file = ...;
CSVWriter writer = CSVWriter.of(file, StandardCharsets.UTF_8);
// 写入数据
Object[] row = ...;
writer.writeLine(row);
writer.close();Csv En (`docs/csv_en.md`)
CSV (comma-separated values) is a widely used data exchange file format that uses commas as delimiters.
fastjson provides high-performance support for reading and writing CSV.
1. Count Rows
Analyze how many rows a CSV file has. If the CSV file has a header, the number of data rows will be one less.
File file = ...;
int rowCount = CSVReader.rowCount(file);2. Analyze File Content
File file = ...;
CSVReader parser = CSVReader.of(file);
// First, read the header (the first line)
parser.readHeader();
// Perform statistical analysis on the data
parser.statAll();
// Get the analysis results for each column
List<StreamReader.ColumnStat> columns = parser.getColumnStats();
// Generate a CREATE TABLE statement based on the column statistics
StringBuilder sql = new StringBuilder();
sql.append("CREATE TABLE ").append(tableName).append(" (\n");
for (int i = 0; i < columns.size(); i++) {
StreamReader.ColumnStat columnStat = columns.get(i);
sql.append('\t')
.append(columnName)
.append(' ')
.append(columnStat.getInferSQLType());
if (i != columns.size() - 1) {
sql.append(',');
}
sql.append("\n");
}
sql.append(");");3. Read File with String Type by Default
File file = ...;
CSVReader parser = CSVReader.of(file);
// If needed, read the header first. If there is no header, this can be skipped.
parser.readHeader();
while (true) {
String[] line = parser.readLine();
if (line == null) {
break;
}
// handler line
}4. Read File by Specifying Data Types for Each Column
File file = ...;
Type[] types = new Type[] {
Integer.class,
Long.class,
String.class ,
Date.class
};
// Construct the CSVReader, passing in the type information for each column
CSVReader parser = CSVReader.of(file, types);
// If needed, read the header first. If there is no header, this can be skipped.
parser.readHeader();
while (true) {
Object[] line = parser.readLineValues();
if (line == null) {
break;
}
// Process the data. The value of each column will correspond to the types passed in when constructing the CSVReader.
Integer v0 = (Integer) line[0];
Long v1 = (Long) line[1];
String v2 = (String) line[2];
Date v3 = (Date) line[3];
}5. Read Each Row into a JavaBean
@Data
class Bean {
long id;
int age;
String name;
Date created;
}
File file = ...;
// Construct the CSVReader, passing in the object type
CSVReader parser = CSVReader.of(file, Bean.class);
// If needed, read the header first. If there is no header, this can be skipped.
parser.readHeader();
while (true) {
Bean object = parser.readLineObject();
if (object == null) {
break;
}
// Process data ...
}5.1 Read JavaBeans Using a Lambda Consumer
File file = ...;
// Construct the CSVReader, passing in the object type
CSVReader parser = CSVReader.of(file, Bean.class);
// Specify whether to read the header first
boolean readHeader = true;
parser.readLineObjectAll(
readHeader,
e -> {
// Process data ...
}
);6. Write to a CSV Format File
File file = ...;
CSVWriter writer = CSVWriter.of(file, StandardCharsets.UTF_8);
// Write data
Object[] row = ...;
writer.writeLine(row);
writer.close();Design Jsonreader Cn (`docs/design_jsonreader_cn.md`)
JSONReader是fastjson2读取JSON数据的底层实现,为了方便不同的输入,分别提供了如下实现:
- JSONReaderUTF16 用于处理输入为char[]的输入,在JDK8下, String会转成char[],使用JSONReaderUTF16实现;在JDK 9或者更高版本,如果coder=1,也是会使用这个实现。
- JSONReaderUTF8 用于处理输入为utf8编码的byte[]
- JSONReaderASCII是JSONReaderUTF8的派生类,用于处理JDK 9之后coder=0的优化
- JSONReaderJSONB 如果输入是jsonb格式数据时,使用JSONReaderJSONB实现,通过相同的API实现两套协议,一套API
class JSONReader { }
class JSONReaderUTF16 extends JSONReader {
char[] chars;
}
class JSONReaderUTF8 extends JSONReader {
byte[] bytes;
}
class JSONReaderASCII extends JSONReaderUTF8 { }
class JSONReaderJSONB extends JSONReader {}Design Jsonreader En (`docs/design_jsonreader_en.md`)
JSONReader is the underlying implementation for reading JSON data in fastjson2. To facilitate different types of input, it provides the following implementations:
- JSONReaderUTF16: Used to process input that is a
char[]. Under JDK 8, aStringis converted to achar[]and processed using theJSONReaderUTF16implementation. On JDK 9 or higher, ifcoder=1, this implementation is also used. - JSONReaderUTF8: Used to process input that is a UTF-8 encoded
byte[]. - JSONReaderASCII: A subclass of
JSONReaderUTF8, used for thecoder=0optimization in JDK 9 and later. - JSONReaderJSONB: If the input is jsonb format data, the
JSONReaderJSONBimplementation is used, allowing two protocols to be handled through the same single API.
class JSONReader { }
class JSONReaderUTF16 extends JSONReader {
char[] chars;
}
class JSONReaderUTF8 extends JSONReader {
byte[] bytes;
}
class JSONReaderASCII extends JSONReaderUTF8 { }
class JSONReaderJSONB extends JSONReader {}Design Jsonwriter Cn (`docs/design_jsonwriter_cn.md`)
JSONWriter是fastjson2序列化的底层实现,针对toJSONString和toJSONBytes两种场景,会使用JSONWriterUTF8和JSONWriterUTF16两种实现。
- JSONWriterUTF16 当使用JSON.toJSONString时,缺省使用JSONWriterUTF16。
- JSONWriterUTF8 当使用JSON.toJSONBytes时,缺省使用JSONWriterUTF8,在使用JSON.toJSONString结合JSONWriter.Feature.OptimizedForAscii使用时,也会用JSONWriterUTF8实现。
- JSONWriterPretty 当JSONWriter.Feature.PrettyFormat启用时,会使用JSONWriterPretty包装一个JSONWriter实现
- JSONWriterJSONB 如果序列化的结果是jsonb格式,使用JSONWriterJSONB实现,通过相同的API实现两套协议,一套API
class JSONWriter { }
class JSONWriterUTF8 extends JSONWriter { }
class JSONWriterUTF16 extends JSONWriter { }
final class JSONWriterPretty extends JSONWriter {
JSONWriter jsonWriter;
JSONWriterPretty(JSONWriter jsonWriter) {
this.jsonWriter = jsonWriter;
}
}
class JSONWriterJSONB extends JSONWriter { }Design Jsonwriter En (`docs/design_jsonwriter_en.md`)
JSONWriter is the underlying implementation for serialization in fastjson2. For the two scenarios of toJSONString and toJSONBytes, the JSONWriterUTF8 and JSONWriterUTF16 implementations are used.
- JSONWriterUTF16: When
JSON.toJSONStringis used,JSONWriterUTF16is used by default. - JSONWriterUTF8: When
JSON.toJSONBytesis used,JSONWriterUTF8is used by default. TheJSONWriterUTF8implementation is also used whenJSON.toJSONStringis combined withJSONWriter.Feature.OptimizedForAscii. - JSONWriterPretty: When
JSONWriter.Feature.PrettyFormatis enabled, aJSONWriterimplementation is wrapped withJSONWriterPretty. - JSONWriterJSONB: If the result of serialization is in jsonb format, the
JSONWriterJSONBimplementation is used, allowing two protocols to be handled through the same single API.
class JSONWriter { }
class JSONWriterUTF8 extends JSONWriter { }
class JSONWriterUTF16 extends JSONWriter { }
final class JSONWriterPretty extends JSONWriter {
JSONWriter jsonWriter;
JSONWriterPretty(JSONWriter jsonWriter) {
this.jsonWriter = jsonWriter;
}
}
class JSONWriterJSONB extends JSONWriter { }Fastjson 1 Upgrade Cn (`docs/fastjson_1_upgrade_cn.md`)
FASTJSON 1.x升级指南
1. 为什么要升级
- 性能更好,具体性能数据 https://github.com/alibaba/fastjson2/wiki/fastjson_benchmark
- 支持JDK新特性,包括JDK 14引入的Record,Lambda表达式的更原生支持,GraalVM Native-Image支持
- 原生支持kotlin
- 支持 JSON Schema https://github.com/alibaba/fastjson2/wiki/json_schema_cn
- 统一文本和二进制API,在RPC、Redis场景也可以使用FASTJSON v2
- 更安全,完全删除autoType白名单,提升安全性 https://github.com/alibaba/fastjson2/wiki/fastjson2_autotype_cn
- 新版本会长期维护,目标为下一个时间提供高性能JSON库,提需求能更快得到响应,提BUG也更快修复
2. 如何升级
2.1. 如何获得最新版本
FASTJSON v2项目目前处于活跃状态,会不定期发布新版本,你可以在fastjson2发布地址中获得最新版本 https://github.com/alibaba/fastjson2/releases
可以两种模式升级:
- 兼容模式
- 使用fastjson v2新的API
2.2. 兼容模式升级
升级可以通过兼容模式升级,兼容模式不需要改代码,但在深度使用的场景,不能做到完全兼容,通过这样的模式升级虽然省事,但请认真测试,遇到问题反馈到 https://github.com/alibaba/fastjson2/issues
- 兼容模式Maven依赖
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson2.version}</version>
</dependency>2.3. 使用新API升级
使用新API是建议的升级方式,使用新的API能获得更多的功能。
- 包名变更
FASTJSONv2和1.x版本使用不同的package,新的package名称是com.alibaba.fastjson2,新package和之前不同,可以实现1.x和2.x共存
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.JSONArray;- Maven依赖
Maven依赖的groupId和1.x不同,使用了新的groupIdcom.alibaba.fastjson2
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>${fastjson2.version}</version>
</dependency>如果你需要用到spring支持的功能,还需要依赖fastjson2-extension
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-extension</artifactId>
<version>${fastjson2.version}</version>
</dependency>如果你是在kotlin中使用fastjson,需要依赖fastjson2-kotlin
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-kotlin</artifactId>
<version>${fastjson2.version}</version>
</dependency>3. 常见问题
3.1. ParserConfig.getGlobalInstance().addAccept()如何兼容
在2.x版本中,ParserConfig添加autoType白名单的功能在ObjectReaderProvider中提供,可以如下的方式配置autoType白名单。
JSONFactory.getDefaultObjectReaderProvider().addAutoTypeAccept("com.mycompany.xxx");3.2. ObjectSerializer 和 ObjectDeserializer 被移除了,有什么新的代替方案
FASTJSON v2中有比较完善的扩展机制,如下:
- Annotation介绍 https://alibaba.github.io/fastjson2/annotations_cn
- Annotation注入介绍 https://alibaba.github.io/fastjson2/mixin_cn
- Feature介绍 https://alibaba.github.io/fastjson2/features_cn
- 使用Mixin注入Annotation定制序列化和反序列化 https://alibaba.github.io/fastjson2/mixin_cn
- 实现ObjectWriter和ObjectReader实现定制序列化和反序列化 https://alibaba.github.io/fastjson2/register_custom_reader_writer_cn
3.3. 常见的类扩展升级映射
| fastjson1 | fastjson2 |
|---|---|
| com.alibaba.fastjson.parser.ParserConfig | com.alibaba.fastjson2.reader.ObjectReaderProvider |
| com.alibaba.fastjson.parser.deserializer.ExtraProcessor | com.alibaba.fastjson2.filter.ExtraProcessor |
| com.alibaba.fastjson.parser.deserializer.ObjectDeserializer | com.alibaba.fastjson2.reader.ObjectReader |
| com.alibaba.fastjson.serializer.AfterFilter | com.alibaba.fastjson2.filter.AfterFilter |
| com.alibaba.fastjson.serializer.BeforeFilter | com.alibaba.fastjson2.filter.BeforeFilter |
| com.alibaba.fastjson.serializer.ContextValueFilter | com.alibaba.fastjson2.filter.ContextValueFilter |
| com.alibaba.fastjson.serializer.LabelFilter | com.alibaba.fastjson2.filter.LabelFilter |
| com.alibaba.fastjson.serializer.NameFilter | com.alibaba.fastjson2.filter.NameFilter |
| com.alibaba.fastjson.serializer.PascalNameFilter | com.alibaba.fastjson2.filter.PascalNameFilter |
| com.alibaba.fastjson.serializer.PropertyFilter | com.alibaba.fastjson2.filter.PropertyFilter |
| com.alibaba.fastjson.serializer.ObjectSerializer | com.alibaba.fastjson2.writer.ObjectWriter |
| com.alibaba.fastjson.serializer.SerializeConfig | com.alibaba.fastjson2.writer.ObjectWriterProvider |
| com.alibaba.fastjson.serializer.ToStringSerializer | com.alibaba.fastjson2.writer.ObjectWriterImplToString |
| com.alibaba.fastjson.serializer.ValueFilter | com.alibaba.fastjson2.filter.ValueFilter |
| com.alibaba.fastjson.serializer.SerializerFeature | com.alibaba.fastjson2.JSONWriter.Feature |
| com.alibaba.fastjson.parser.Feature | com.alibaba.fastjson2.JSONReader.Feature |
3.4 SerializerFeature.UseISO8601DateFormat在fastjson2的替代方案
fastjson2的JSONWriter.Feature没有和UseISO8601DateFormat的Feature,代替方法是使用format="iso8601",如下:
import com.alibaba.fastjson2.JSON;
String format = "iso8601";
JSON.toJSONString(obj, format);3.5 SerializerFeature.DisableCircularReferenceDetect在fastjson2的替代方案
在fastjson2中,代替的是JSONWriter.Feature.ReferenceDetection,但语义相反,缺省不一样。fastjson2中的JSONWriter.Feature.ReferenceDetection缺省是关闭的,而fastjson1缺省是打开的。
3.6 SerializerFeature.SortField在fastjson2的替代方案
不需要,在fastjson2中,JSONObject继承自LinkedHashMap,不需要配置这个Feature
3.7 SerializerFeature.WriteDateUseDateFormat在fastjson2的替代方案
在fastjson2中的缺省行为就是使用dateFormat,如果要修改为成和fastjson 1.x一样的行为,需要配置format = "millis",如下:
import com.alibaba.fastjson2.JSON;
String format = "millis";
JSON.toJSONString(obj, format);Fastjson 1 Upgrade En (`docs/fastjson_1_upgrade_en.md`)
FASTJSON 1.x Upgrade Guide
1. Why Upgrade?
- Better Performance: For detailed performance data, see https://github.com/alibaba/fastjson2/wiki/fastjson_benchmark_en
- Support for New JDK Features: Includes support for Records introduced in JDK 14, more native support for Lambda expressions, and GraalVM Native-Image support.
- Native Kotlin Support
- Support for JSON Schema: https://github.com/alibaba/fastjson2/wiki/json_schema_en
- Unified Text and Binary API: FASTJSON v2 can also be used in RPC and Redis scenarios.
- More Secure: The autoType whitelist has been completely removed to enhance security. https://github.com/alibaba/fastjson2/wiki/fastjson2_autotype_en
- Long-Term Maintenance: The new version will be maintained for the long term, aiming to provide a high-performance JSON library for the future. Feature requests will get faster responses, and bugs will be fixed more quickly.
2. How to Upgrade
2.1. How to Get the Latest Version
The FASTJSON v2 project is currently active, and new versions are released from time to time. You can get the latest version from the fastjson2 release page: https://github.com/alibaba/fastjson2/releases
You can upgrade in two modes:
- Compatibility Mode
- Using the new fastjson v2 API
2.2. Upgrading in Compatibility Mode
You can upgrade using compatibility mode, which does not require code changes. However, in scenarios of deep usage, it may not be fully compatible. Although this mode is convenient, please test thoroughly and report any issues to https://github.com/alibaba/fastjson2/issues.
- Compatibility Mode Maven Dependency
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson2.version}</version>
</dependency>2.3. Upgrading Using the New API
Using the new API is the recommended upgrade method, as it provides access to more features.
- Package Name Change
FASTJSON v2 and v1.x use different package names. The new package name iscom.alibaba.fastjson2. Because the new package is different, v1.x and v2.x can coexist.
import com.alibaba.fastjson2.JSON;
import com.alibaba.fastjson2.JSONObject;
import com.alibaba.fastjson2.JSONArray;- Maven Dependency
ThegroupIdfor the Maven dependency is different from v1.x; it uses the newgroupIdcom.alibaba.fastjson2.
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>${fastjson2.version}</version>
</dependency>If you need Spring support, you also need to depend on fastjson2-extension:
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-extension</artifactId>
<version>${fastjson2.version}</version>
</dependency>If you are using fastjson in Kotlin, you need to depend on fastjson2-kotlin:
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-kotlin</artifactId>
<version>${fastjson2.version}</version>
</dependency>3. Common Issues
3.1. How to make `ParserConfig.getGlobalInstance().addAccept()` compatible?
In v2, the functionality to add an autoType whitelist to ParserConfig is provided by ObjectReaderProvider. You can configure the autoType whitelist as follows:
JSONFactory.getDefaultObjectReaderProvider().addAutoTypeAccept("com.mycompany.xxx");3.2. `ObjectSerializer` and `ObjectDeserializer` have been removed. What are the new alternatives?
FASTJSON v2 has a more comprehensive extension mechanism, as follows:
- Annotation Introduction: https://alibaba.github.io/fastjson2/annotations_en
- Annotation Mixin Introduction: https://alibaba.github.io/fastjson2/mixin_en
- Feature Introduction: https://alibaba.github.io/fastjson2/features_en
- Using Mixin to customize serialization and deserialization: https://alibaba.github.io/fastjson2/mixin_en
- Implementing
ObjectWriterandObjectReaderfor custom serialization and deserialization: https://alibaba.github.io/fastjson2/register_custom_reader_writer_en
3.3. Common Class Extension Upgrade Mapping
| fastjson1 | fastjson2 |
|---|---|
| com.alibaba.fastjson.parser.ParserConfig | com.alibaba.fastjson2.reader.ObjectReaderProvider |
| com.alibaba.fastjson.parser.deserializer.ExtraProcessor | com.alibaba.fastjson2.filter.ExtraProcessor |
| com.alibaba.fastjson.parser.deserializer.ObjectDeserializer | com.alibaba.fastjson2.reader.ObjectReader |
| com.alibaba.fastjson.serializer.AfterFilter | com.alibaba.fastjson2.filter.AfterFilter |
| com.alibaba.fastjson.serializer.BeforeFilter | com.alibaba.fastjson2.filter.BeforeFilter |
| com.alibaba.fastjson.serializer.ContextValueFilter | com.alibaba.fastjson2.filter.ContextValueFilter |
| com.alibaba.fastjson.serializer.LabelFilter | com.alibaba.fastjson2.filter.LabelFilter |
| com.alibaba.fastjson.serializer.NameFilter | com.alibaba.fastjson2.filter.NameFilter |
| com.alibaba.fastjson.serializer.PascalNameFilter | com.alibaba.fastjson2.filter.PascalNameFilter |
| com.alibaba.fastjson.serializer.PropertyFilter | com.alibaba.fastjson2.filter.PropertyFilter |
| com.alibaba.fastjson.serializer.ObjectSerializer | com.alibaba.fastjson2.writer.ObjectWriter |
| com.alibaba.fastjson.serializer.SerializeConfig | com.alibaba.fastjson2.writer.ObjectWriterProvider |
| com.alibaba.fastjson.serializer.ToStringSerializer | com.alibaba.fastjson2.writer.ObjectWriterImplToString |
| com.alibaba.fastjson.serializer.ValueFilter | com.alibaba.fastjson2.filter.ValueFilter |
| com.alibaba.fastjson.serializer.SerializerFeature | com.alibaba.fastjson2.JSONWriter.Feature |
| com.alibaba.fastjson.parser.Feature | com.alibaba.fastjson2.JSONReader.Feature |
3.4 Alternative for `SerializerFeature.UseISO8601DateFormat` in fastjson2
fastjson2's JSONWriter.Feature does not have a feature corresponding to UseISO8601DateFormat. The alternative is to use format="iso8601", as shown below:
import com.alibaba.fastjson2.JSON;
String format = "iso8601";
JSON.toJSONString(obj, format);3.5 Alternative for `SerializerFeature.DisableCircularReferenceDetect` in fastjson2
In fastjson2, the alternative is JSONWriter.Feature.ReferenceDetection, but the semantics are opposite, and the default is different. JSONWriter.Feature.ReferenceDetection in fastjson2 is disabled by default, whereas in fastjson1 it was enabled by default.
3.6 Alternative for `SerializerFeature.SortField` in fastjson2
Not needed. In fastjson2, JSONObject inherits from LinkedHashMap, so this feature is not necessary.
3.7 Alternative for `SerializerFeature.WriteDateUseDateFormat` in fastjson2
The default behavior in fastjson2 is to use a date format. To change it to behave like fastjson 1.x (outputting milliseconds), you need to configure format = "millis", as shown below:
import com.alibaba.fastjson2.JSON;
String format = "millis";
JSON.toJSONString(obj, format);Features Cn (`docs/features_cn.md`)
通过Features配置序列化和反序列化的行为
1. Feature介绍
在fastjson 2.x中,有两个Feature,分别用来配置序列化和反序列化的行为。
- JSONWriter.Feature 配置序列化的行为
- JSONReader.Feature 配置反序列化的行为
2. 在JSON的toJSONString和parse方法中使用Feature
2.1 在JSON的toJSONString方法中使用JSONWriter.Feature
Bean bean = ...;
String json = JSON.toJSONString(bean, JSONWriter.Feature.WriteNulls); // 输出对象中值为null的字段2.2 在JSON的parse方法中使用JSONReader.Feature
String jsonStr = ...;
Bean bean = JSON.parseObject(jsonStr, Bean.class, JSONReader.Feature.UseBigDecimalForDoubles); // 将小数数值读取为BigDecimal3. 在JSONField和JSONType上配置features
class Model {
@JSONField(serializeFeatures = JSONWriter.Feature.BrowserCompatible)
public long value;
}也可以在类级别使用JSONType注解:
@JSONType(serializeFeatures = JSONWriter.Feature.WriteMapNullValue)
public class Model {
public String name;
public int age;
}4. JSONReader.Feature 介绍
| 核心解析与对象映射机制 | |
|---|---|
| FieldBased | 基于字段反序列化,如果不配置,会默认基于public的field和getter方法反序列化。配置后,会基于非static的field(包括private)做反序列化。在fieldbase配置下会更安全 |
| UseDefaultConstructorAsPossible | 尽可能使用缺省构造函数,在fieldBase打开这个选项没打开的时候,会可能用Unsafe.allocateInstance来实现 |
| UseNativeObject | 默认是使用JSONObject和JSONArray,配置后会使用LinkedHashMap和ArrayList |
| SupportArrayToBean | 支持数组映射到Bean的方式 |
| DisableReferenceDetect | 禁用引用检测 |
| IgnoreCheckClose | 忽略资源清理检查 |
| 类型安全与多态 | |
|---|---|
| SupportAutoType | 支持自动类型,要读取带"@type"类型信息的JSON数据(已弃用,不推荐在生产环境使用,建议使用 AutoTypeBeforeHandler) |
| SupportClassForName | 支持类型为Class的字段,使用Class.forName。为了安全这个是默认关闭的 |
| ErrorOnNotSupportAutoType | 遇到AutoType报错(缺省是忽略) |
| IgnoreAutoTypeNotMatch | 忽略AutoType不匹配 |
| 容错与兼容性解析 | |
|---|---|
| SupportSmartMatch | 默认下是camel case精确匹配,打开这个后,能够智能识别camel/upper/pascal/snake/Kebab五种case |
| AllowUnQuotedFieldNames | 支持不带双引号的字段名 |
| DisableSingleQuote | 不允许在key和value中使用单引号 |
| NonStringKeyAsString | 非String类型的Key当做String处理 |
| DuplicateKeyValueAsArray | 重复Key的Value不是替换而是组合成数组 |
| IgnoreNoneSerializable | 反序列化忽略非Serializable类型的字段 |
| NullOnError | 反序列化错误时返回null |
| NonErrorOnNumberOverflow | 忽略数字溢出报错 |
| DisableStringArrayUnwrapping | 禁用单元素字符串数组解包(["value"]默认解析为"value",启用特性后,输出为["value"]) |
| 数据转换与精细化处理 | |
|---|---|
| InitStringFieldAsEmpty | 初始化String字段为空字符串"" |
| TrimString | 对读取到的字符串值做trim处理 |
| Base64StringAsByteArray | 将Base64格式的字符串反序列化为byte[] |
| UseBigDecimalForFloats | 默认配置会使用BigDecimal来parse小数,打开后会使用Float |
| UseBigDecimalForDoubles | 默认配置会使用BigDecimal来parse小数,打开后会使用Double |
| EmptyStringAsNull | 空字符串解析为null |
| NonZeroNumberCastToBooleanAsTrue | 非零数字转为布尔 true |
| UseBigIntegerForInts | 整型解析为 BigInteger |
| UseLongForInts | 整型解析为 Long |
| UseDoubleForDecimals | 小数解析为 Double |
| 严格控制与拦截 | |
|---|---|
| IgnoreSetNullValue | 忽略输入为null的字段 |
| IgnoreNullPropertyValue | 忽略null属性值 |
| ErrorOnEnumNotMatch | 默认Enum的name不匹配时会忽略,打开后不匹配会抛异常 |
| ErrorOnNoneSerializable | 非Serializable对象报错 |
| ErrorOnNullForPrimitives | 基础类型遇 null 报错 |
| ErrorOnUnknownProperties | 未知属性报错 |
5. JSONWriter.Feature 介绍
| 核心序列化机制 | |
|---|---|
| FieldBased | 基于字段序列化,如果不配置,会默认基于public的field和getter方法序列化。配置后,会基于非static的field(包括private)做序列化。 |
| BeanToArray | 将对象序列为[101,"XX"]这样的数组格式,这样的格式会更小 |
| ReferenceDetection | 打开引用检测,这个缺省是关闭的,和fastjson 1.x不一致 |
| LargeObject | 这个是一个保护措施,是为了防止序列化有循环引用对象消耗过大资源的保护措施。 |
| IgnoreErrorGetter | 忽略getter方法的错误 |
| IgnoreNonFieldGetter | 忽略无字段的 getter |
| OptimizedForAscii | 为 ASCII 字符优化 |
| 空值与默认值控制 | |
|---|---|
| WriteNulls | 序列化输出空值字段 |
| WriteMapNullValue | 输出 Map 中的 null 值 |
| IgnoreEmpty | 忽略空集合、空字符串等,不输出到 JSON |
| NotWriteDefaultValue | 当字段的值为缺省值时,不输出,这个能节省序列化后结果的大小 |
| NotWriteEmptyArray | 数组类型字段当length为0时不输出 ("@Deprecated",推荐使用 IgnoreEmpty) |
| NullAsDefaultValue | 将null值输出为缺省值,整数类型的Number输出为0,小数类型的Number输出为0.0,Boolean类型输出为false,String类型输出为"",Character类型输出为\u0000,数组和Collection类型输出为[],其余类型输出{}。 |
| WriteNullListAsEmpty | 将List类型字段的空值序列化输出为空数组"[]" |
| WriteNullStringAsEmpty | 将String类型字段的空值序列化输出为空字符串"" |
| WriteNullNumberAsZero | 将Number类型字段的空值序列化输出为0 |
| WriteNullBooleanAsFalse | 将Boolean类型字段的空值序列化输出为false |
| 序列化类型信息 | |
|---|---|
| WriteClassName | 序列化时输出类型信息 |
| NotWriteRootClassName | 打开WriteClassName的同时,不输出根对象的类型信息 |
| NotWriteHashMapArrayListClassName | 打开WriteClassName的同时,不输出类型为HashMap/ArrayList类型对象的类型信息,反序列结合UseNativeObject使用,能节省序列化结果的大小 |
| NotWriteSetClassName | 当打开WriteClassName时又不想输出Set的类型信息,使用这个Feature |
| NotWriteNumberClassName | 当打开WriteClassName时又不想输出Number的类型信息,比如L/S/B/F/D这种后缀,使用这个Feature |
| WriteThrowableClassName | 序列化Throwable时带上类型信息 |
| 特定类型的转换策略 | |
|---|---|
| WriteEnumsUsingName | 序列化enum使用name |
| WriteEnumUsingToString | 序列化enum使用toString方法 |
| WriteEnumUsingOrdinal | 序列化Enum使用Ordinal,缺省是name |
| WriteByteArrayAsBase64 | 字节数组转 Base64 |
| WriteBooleanAsNumber | 将true输出为1,false输出为0 |
| WriteLongAsString | 将Long序列化为String |
| WriteBigDecimalAsPlain | 序列化BigDecimal使用toPlainString,避免科学计数法 |
| WriteFloatSpecialAsString | 启用后,NaN/Infinity将被序列化为\“NaN\”、\“Infinity\”、\“-Infinity\” |
| WriteNonStringValueAsString | 将非String类型的值输出为String,不包括对象和数组类型 |
| WritePairAsJavaBean | 将 Apache Commons 包中的Pair对象当做JavaBean序列化 |
| WriterUtilDateAsMillis | Date 转为毫秒时间戳 |
| 结构与格式化美化 | |
|---|---|
| PrettyFormat | 格式化输出 |
| PrettyFormatWith2Space | 2空格美化缩进 |
| PrettyFormatWith4Space | 4空格美化缩进 |
| SortMapEntriesByKeys | 对Map中的KeyValue按照Key做排序后再输出。用于需要确定性 Key 顺序的场景(如签名验证) |
| UnquoteFieldName | 不带引号输出Key |
| UseSingleQuotes | 使用单引号 |
| WriteNameAsSymbol | 将字段名按照symbol输出,这个仅在JSONB下起作用 |
| WriteNonStringKeyAsString | 将Map中的非String类型的Key当做String类型输出 |
| 安全与跨端兼容 | |
|---|---|
| BrowserCompatible | 在大范围超过JavaScript支持的整数,输出为字符串格式 |
| BrowserSecure | 浏览器安全,将会'<' '>' '(' ')'字符做转义输出 |
| EscapeNoneAscii | 将超出 7 位 ASCII 范围的字符(如中文)使用特定转义 |
| ErrorOnNoneSerializable | 序列化非Serializable对象时报错 |
| IgnoreNoneSerializable | 序列化忽略非Serializable类型的字段 |
6. 使用示例
6.1 序列化示例
// 基本使用
User user = new User(\"张三\", 25, null);
String json = JSON.toJSONString(user, JSONWriter.Feature.WriteNulls);
// 多个Feature组合使用
String json2 = JSON.toJSONString(user,
JSONWriter.Feature.WriteNulls,
JSONWriter.Feature.PrettyFormat);
// 使用BeanToArray特性
String json3 = JSON.toJSONString(user, JSONWriter.Feature.BeanToArray);6.2 反序列化示例
// 基本使用
String json = \"{\\\"name\\\":\\\"张三\\\",\\\"age\\\":25}\";
User user = JSON.parseObject(json, User.class, JSONReader.Feature.SupportSmartMatch);
// 多个Feature组合使用
User user2 = JSON.parseObject(json, User.class,
JSONReader.Feature.SupportSmartMatch,
JSONReader.Feature.InitStringFieldAsEmpty);7. 1.x 特性变更指南
7.1 默认开启的特性
在 fastjson 1.x 中,默认开启的特性如下:
序列化:
SerializerFeature.QuoteFieldNamesSerializerFeature.SkipTransientFieldSerializerFeature.WriteEnumUsingNameSerializerFeature.SortField
反序列化:
Feature.AutoCloseSourceFeature.InternFieldNamesFeature.UseBigDecimalFeature.AllowUnQuotedFieldNamesFeature.AllowSingleQuotesFeature.AllowArbitraryCommasFeature.SortFeidFastMatchFeature.IgnoreNotMatch
在 fastjson 2.x 中,所有特性默认关闭。
7.2 1.x特性变更
序列化:
QuoteFieldNames:2.x默认支持,无需配置。且2.x支持UnquoteFieldName特性UseISO8601DateFormat:2.x中替代方案如下:JSON.configWriterDateFormat("iso8601")(全局配置)JSON.toJSONString(bean, "iso8601")@JSONField(format = "iso8601")
SkipTransientField;2.x默认支持,若要关闭,方案如下:- JVM参数配置
-Dfastjson2.writer.skipTransient=false(全局配置) JSONFactory.setDefaultSkipTransient(false)(全局配置)@JSONType(skipTransient = false)@JSONField(skipTransient = false)
- JVM参数配置
SortField:2.x默认支持,无需配置WriteDateUseDateFormat:2.x中替代方案如下:JSON.toJSONString(bean, "millis")- 使用2.0.58中新增加的特性
JSONWriter.Feature.WriterUtilDateAsMillis
DisableCircularReferenceDetect:1.x中默认有循环引用检测,2.x则默认关闭。2.x若要开启,使用特性ReferenceDetectionWriteEnumUsingName:2.x中默认关闭WriteSlashAsSpecial:2.x未支持WriteTabAsSpecial、DisableCheckSpecialChar在1.x中已弃用- 其余1.x序列化特性无变化
反序列化:
AllowArbitraryCommas:2.x的语法更加严格,不支持多重逗号AllowComment:2.x默认支持,无需配置AllowISO8601DateFormat:2.x默认支持,也可通过以下方式显式指定:JSON.configReaderDateFormat("iso8601")(全局配置)JSON.parseObject(str, Bean.class, "iso8601")
AllowSingleQuotes:2.x默认支持,无需配置AutoCloseSource(反序列化不完整JSON抛出异常):2.x默认支持,无需配置CustomMapDeserializer:2.x未支持DisableCircularReferenceDetect:更名为DisableReferenceDetectDisableFieldSmartMatch:替换为SupportSmartMatch(1.x中智能匹配默认开启,2.x中智能匹配默认关闭)DisableSpecialKeyDetect:2.x默认支持,无需配置IgnoreAutoType:2.x默认关闭AutoType功能,缺省配置下是安全的IgnoreNotMatch:2.x默认支持,无需配置OrderedField(反序列化为JSONObject、JSONArray时,保证声明顺序):2.x默认支持,无需配置SupportNonPublicField:可替换为FieldBasedSafeMode:2.x可通过JVM参数配置-Dfastjson2.parser.safeMode=trueTrimStringFieldValue:可替换为TrimStringUseBigDecimal:替换为UseBigDecimalForFloats、UseBigDecimalForDoublesUseNativeJavaObject:更名为UseNativeObjectUseObjectArray(JSON数组解析为Object[]而非ArrayList):2.x未支持- 其余1.x反序列化特性无变化
8. 最佳实践建议
安全性考虑:
- 默认情况下不要开启
SupportAutoType,除非确实需要处理带类型信息的JSON - 对于不受信任的数据源,谨慎使用
FieldBased特性
- 默认情况下不要开启
性能优化:
- 对于大数据量的序列化,可以考虑使用
BeanToArray特性来减小JSON体积 - 在需要保持字段顺序的场景下,使用
MapSortField特性
- 对于大数据量的序列化,可以考虑使用
兼容性处理:
- 在Web前端场景中,使用
BrowserCompatible来处理大整数 - 对于需要严格数据格式的场景,开启
ErrorOnEnumNotMatch来及时发现枚举不匹配问题
- 在Web前端场景中,使用
空值处理:
- 根据业务需求选择合适的空值处理策略,如
WriteNulls、WriteNullStringAsEmpty等
- 根据业务需求选择合适的空值处理策略,如
Features En (`docs/features_en.md`)
Configure serialization and deserialization with `Features`
1. Feature Introduction
In fastjson 2.x, there are two Features, which are used to configure the behavior of serialization and deserialization respectively.
- JSONWriter.Feature Configure serialization behavior
- JSONReader.Feature Configure deserialization behavior
2. Using Feature in JSON `toJSONString` and `parseObject` methods
2.1 Using `JSONWriter.Feature` in JSON `toJSONString` method
Bean bean = ...;
String json = JSON.toJSONString(bean, JSONWriter.Feature.WriteNulls); // Fields in the output object whose value is null2.2 Using `JSONReader.Feature` in JSON `parseObject` method
String jsonStr = ...;
Bean bean = JSON.parseObject(jsonStr, Bean.class, JSONReader.Feature.UseBigDecimalForDoubles); // Read decimal values as BigDecimal3. Configure Features on `JSONField` and `JSONType`
class Model {
@JSONField(serializeFeatures = JSONWriter.Feature.BrowserCompatible)
public long value;
}You can also use the @JSONType annotation at the class level:
@JSONType(serializeFeatures = JSONWriter.Feature.WriteMapNullValue)
public class Model {
public String name;
public int age;
}4. JSONReader.Feature Introduction
| Core Parsing and Object Mapping Mechanism | |
|---|---|
| FieldBased | Based on field deserialization. If not configured, defaults to public fields and getter methods for deserialization. When configured, it deserializes based on non-static fields (including private). Deserialization is safer under the FieldBased configuration. |
| UseDefaultConstructorAsPossible | Use the default constructor as much as possible. If this option is not enabled while FieldBased is open, it may use Unsafe.allocateInstance to instantiate objects. |
| UseNativeObject | Defaults to using JSONObject and JSONArray. When configured, it will use LinkedHashMap and ArrayList. |
| SupportArrayToBean | Supports mapping arrays to Beans. |
| DisableReferenceDetect | Disable reference detection. |
| IgnoreCheckClose | Ignore resource cleanup checks. |
| Type Safety and Polymorphism | |
|---|---|
| SupportAutoType | Supports automatic typing. To read JSON data with "@type" type information.(Deprecated, not recommended for production use; use AutoTypeBeforeHandler instead) |
| SupportClassForName | Supports fields of Class type, using Class.forName. For security, this is disabled by default. |
| ErrorOnNotSupportAutoType | Throw an error when encountering AutoType (ignored by default). |
| IgnoreAutoTypeNotMatch | Ignore AutoType mismatch. |
| Fault Tolerance and Compatibility Parsing | |
|---|---|
| SupportSmartMatch | Defaults to exact camel case match. When enabled, it can intelligently recognize five cases: camel, upper, pascal, snake, and Kebab. |
| AllowUnQuotedFieldNames | Supports field names without double quotes. |
| DisableSingleQuote | Disallow the use of single quotes in keys and values. |
| NonStringKeyAsString | Treat non-String keys as Strings. |
| DuplicateKeyValueAsArray | The value of a duplicate key is combined into an array instead of being replaced. |
| IgnoreNoneSerializable | Ignore non-Serializable fields during deserialization. |
| NullOnError | Return null on deserialization error. |
| NonErrorOnNumberOverflow | Ignore number overflow errors. |
| DisableStringArrayUnwrapping | Disable unwrapping of single-element string arrays (["value"] is parsed as "value" by default; when enabled, it outputs as ["value"]). |
| Data Conversion and Fine-grained Processing | |
|---|---|
| InitStringFieldAsEmpty | Initialize String fields as empty strings "". |
| TrimString | Trim the read string values. |
| Base64StringAsByteArray | Deserialize Base64 format strings into byte[]. |
| UseBigDecimalForFloats | The default configuration uses BigDecimal to parse decimals. When enabled, it will use Float. |
| UseBigDecimalForDoubles | The default configuration uses BigDecimal to parse decimals. When enabled, it will use Double. |
| EmptyStringAsNull | Parse empty strings as null. |
| NonZeroNumberCastToBooleanAsTrue | Cast non-zero numbers to boolean true. |
| UseBigIntegerForInts | Parse integers as BigInteger. |
| UseLongForInts | Parse integers as Long. |
| UseDoubleForDecimals | Parse decimals as Double. |
| Strict Control and Interception | |
|---|---|
| IgnoreSetNullValue | Ignore fields where the input is null. |
| IgnoreNullPropertyValue | Ignore null property values. |
| ErrorOnEnumNotMatch | By default, enum name mismatches are ignored. When enabled, mismatches will throw an exception. |
| ErrorOnNoneSerializable | Throw an error for non-Serializable objects. |
| ErrorOnNullForPrimitives | Throw an error when primitive types encounter null. |
| ErrorOnUnknownProperties | Throw an error for unknown properties. |
5. JSONWriter.Feature Introduction
| Core Serialization Mechanism | |
|---|---|
| FieldBased | Based on field serialization. If not configured, defaults to public fields and getter methods for serialization. When configured, it serializes based on non-static fields (including private). |
| BeanToArray | Serialize objects into an array format like [101,"XX"], which results in a smaller size. |
| ReferenceDetection | Enable reference detection. This is disabled by default, which is inconsistent with fastjson 1.x. |
| LargeObject | A protective measure to prevent excessive resource consumption caused by serializing objects with circular references. |
| IgnoreErrorGetter | Ignore errors from getter methods. |
| IgnoreNonFieldGetter | Ignore getter methods that do not correspond to fields. |
| OptimizedForAscii | Optimize for ASCII characters. |
| Null and Default Value Control | |
|---|---|
| WriteNulls | Serialize and output null value fields. |
| WriteMapNullValue | Output null values in Map. |
| IgnoreEmpty | Ignore empty collections, empty strings, etc., and do not output them to JSON. |
| NotWriteDefaultValue | Do not output when the field's value is the default value; this saves the size of the serialized result. |
| NotWriteEmptyArray | Do not output array type fields when the length is 0. ("@Deprecated", recommend using IgnoreEmpty) |
| NullAsDefaultValue | Output null values as default values: Number of integer type outputs as 0, Number of decimal type outputs as 0.0, Boolean type outputs as false, String type outputs as "", Character type outputs as \u0000, array and Collection types output as [], and other types output as {}. |
| WriteNullListAsEmpty | Serialize null values of List type fields as empty arrays "[]". |
| WriteNullStringAsEmpty | Serialize null values of String type fields as empty strings "". |
| WriteNullNumberAsZero | Serialize null values of Number type fields as 0. |
| WriteNullBooleanAsFalse | Serialize null values of Boolean type fields as false. |
| Serialization Type Information | |
|---|---|
| WriteClassName | Output type information during serialization. |
| NotWriteRootClassName | When WriteClassName is enabled, do not output the type information of the root object. |
| NotWriteHashMapArrayListClassName | When WriteClassName is enabled, do not output type information for objects of HashMap/ArrayList type. Combined with UseNativeObject during deserialization, it saves the serialization result size. |
| NotWriteSetClassName | When WriteClassName is enabled and you do not want to output Set type information, use this Feature. |
| NotWriteNumberClassName | When WriteClassName is enabled and you do not want to output Number type information, such as L/S/B/F/D suffixes, use this Feature. |
| WriteThrowableClassName | Include type information when serializing Throwable objects. |
| Type-Specific Conversion Strategies | |
|---|---|
| WriteEnumsUsingName | Serialize enums using name. |
| WriteEnumUsingToString | Serialize enums using the toString method. |
| WriteEnumUsingOrdinal | Serialize enums using Ordinal; default is name. |
| WriteByteArrayAsBase64 | Convert byte arrays to Base64. |
| WriteBooleanAsNumber | Output true as 1, false as 0. |
| WriteLongAsString | Serialize Long as String. |
| WriteBigDecimalAsPlain | Serialize BigDecimal using toPlainString to avoid scientific notation. |
| WriteFloatSpecialAsString | When enabled, NaN/Infinity will be serialized as "NaN", "Infinity", "-Infinity". |
| WriteNonStringValueAsString | Output non-String type values as Strings, excluding object and array data types. |
| WritePairAsJavaBean | Serialize Pair objects from the Apache Commons package as JavaBeans. |
| WriterUtilDateAsMillis | Convert Date to millisecond timestamp. |
| Structure and Formatting Beautification | |
|---|---|
| PrettyFormat | Format output. |
| PrettyFormatWith2Space | 2-space formatting indentation. |
| PrettyFormatWith4Space | 4-space formatting indentation. |
| SortMapEntriesByKeys | Sort Map KeyValues by Key before outputting. Required in scenarios that need deterministic key order (e.g., signature verification). |
| UnquoteFieldName | Output Key without quotes. |
| UseSingleQuotes | Use single quotes. |
| WriteNameAsSymbol | Output field names as symbols; this only works under JSONB. |
| WriteNonStringKeyAsString | Output non-String type Keys in Map as String types. |
| Security and Cross-Platform Compatibility | |
|---|---|
| BrowserCompatible | Output integers that greatly exceed JavaScript's supported range in string format. |
| BrowserSecure | Browser security; will escape '<' '>' '(' ')' characters for output. |
| EscapeNoneAscii | Escape characters beyond the 7-bit ASCII range (such as Chinese) using specific escaping. |
| ErrorOnNoneSerializable | Throw an error when serializing non-Serializable objects. |
| IgnoreNoneSerializable | Ignore non-Serializable type fields during serialization. |
6. Usage Examples
6.1 Serialization Examples
// Basic usage
User user = new User("John", 25, null);
String json = JSON.toJSONString(user, JSONWriter.Feature.WriteNulls);
// Combining multiple Features
String json2 = JSON.toJSONString(user,
JSONWriter.Feature.WriteNulls,
JSONWriter.Feature.PrettyFormat);
// Using BeanToArray feature
String json3 = JSON.toJSONString(user, JSONWriter.Feature.BeanToArray);6.2 Deserialization Examples
// Basic usage
String json = "{\"name\":\"John\",\"age\":25}";
User user = JSON.parseObject(json, User.class, JSONReader.Feature.SupportSmartMatch);
// Combining multiple Features
User user2 = JSON.parseObject(json, User.class,
JSONReader.Feature.SupportSmartMatch,
JSONReader.Feature.InitStringFieldAsEmpty);7. 1.x Feature Migration Guide
7.1 Features Enabled by Default
In fastjson 1.x, the default enabled features are as follows:
Serialization
SerializerFeature.QuoteFieldNamesSerializerFeature.SkipTransientFieldSerializerFeature.WriteEnumUsingNameSerializerFeature.SortField
Deserialization
Feature.AutoCloseSourceFeature.InternFieldNamesFeature.UseBigDecimalFeature.AllowUnQuotedFieldNamesFeature.AllowSingleQuotesFeature.AllowArbitraryCommasFeature.SortFeidFastMatchFeature.IgnoreNotMatch
In fastjson 2.x, all features are OFF by default.
7.2 Changes from 1.x to 2.x
Serialization:
QuoteFieldNames: Enabled by default in 2.x; no configuration required. And 2.x supports theUnquoteFieldNamefeature.UseISO8601DateFormat: Replaced in 2.x by:JSON.configWriterDateFormat("iso8601")(global)JSON.toJSONString(bean, "iso8601")@JSONField(format = "iso8601")
SkipTransientField: Enabled by default in 2.x. To disable:- JVM system property
-Dfastjson2.writer.skipTransient=false JSONFactory.setDefaultSkipTransient(false)@JSONType(skipTransient = false)@JSONField(skipTransient = false)
- JVM system property
SortField: Enabled by default in 2.x; no configuration required.WriteDateUseDateFormat: Alternatives in 2.x:JSON.toJSONString(bean, "millis")JSONWriter.Feature.WriterUtilDateAsMillis(since 2.0.58)
DisableCircularReferenceDetect: 1.x detects circular refs by default; 2.x does not. To turn detection on in 2.x useReferenceDetection.WriteEnumUsingName: Disabled by default in 2.x.WriteSlashAsSpecial: Not supported in 2.x.WriteTabAsSpecial&DisableCheckSpecialChar: Already deprecated in 1.x; removed in 2.x.- All other 1.x serialization features remain unchanged.
Deserialization:
AllowArbitraryCommas: 2.x uses strict syntax; multiple commas are not allowed.AllowComment: Enabled by default in 2.x; no configuration required.AllowISO8601DateFormat: Enabled by default in 2.x. Explicit settings:JSON.configReaderDateFormat("iso8601")JSON.parseObject(str, Bean.class, "iso8601")
AllowSingleQuotes: Enabled by default in 2.x; no configuration required.AutoCloseSource(throw on incomplete JSON): Enabled by default in 2.x; no configuration required.CustomMapDeserializer: Not supported in 2.x.DisableCircularReferenceDetect: Renamed toDisableReferenceDetect.DisableFieldSmartMatch: Replaced bySupportSmartMatch. (Smart matching was ON in 1.x, OFF by default in 2.x.)DisableSpecialKeyDetect: Enabled by default in 2.x; no configuration required.IgnoreAutoType: 2.x disables AutoType by default; safe out-of-the-box.IgnoreNotMatch: Enabled by default in 2.x; no configuration required.OrderedField(keep declaration order for JSONObject / JSONArray): Enabled by default in 2.x; no configuration required.SupportNonPublicField: UseFieldBasedin 2.x.SafeMode: 2.x: JVM system property-Dfastjson2.parser.safeMode=true.TrimStringFieldValue: UseJSONReader.Feature.TrimStringin 2.x.UseBigDecimal: Split intoUseBigDecimalForFloatsandUseBigDecimalForDoublesin 2.x.UseNativeJavaObject: Renamed toUseNativeObject.UseObjectArray(parse JSON arrays asObject[]instead ofArrayList): Not supported in 2.x.- All other 1.x deserialization features remain unchanged.
8. Best Practices
Security Considerations:
- Do not enable
SupportAutoTypeby default unless you really need to process JSON with type information - Be cautious when using the
FieldBasedfeature with untrusted data sources
- Do not enable
Performance Optimization:
- For large data serialization, consider using the
BeanToArrayfeature to reduce JSON size - Use the
MapSortFieldfeature when field order needs to be maintained
- For large data serialization, consider using the
Compatibility Handling:
- Use
BrowserCompatiblefor web front-end scenarios to handle large integers - Enable
ErrorOnEnumNotMatchin scenarios requiring strict data format to quickly identify enum mismatches
- Use
Null Value Handling:
- Choose appropriate null value handling strategies based on business requirements, such as
WriteNulls,WriteNullStringAsEmpty, etc.
- Choose appropriate null value handling strategies based on business requirements, such as
Jsontype Seealso Cn (`docs/jsontype_seealso_cn.md`)
在fastjson中,可以使用Annotation JSONType#seeAlso配置,类似于JAXB中的XmlSeeAlso。用法如下:
JavaBean Config
@JSONType(seeAlso={Dog.class, Cat.class})
public static class Animal {
}
@JSONType(typeName = "dog")
public static class Dog extends Animal {
public String dogName;
}
@JSONType(typeName = "cat")
public static class Cat extends Animal {
public String catName;
}Usage
Dog dog = new Dog();
dog.dogName = "dog1001";
String text = JSON.toJSONString(dog, SerializerFeature.WriteClassName);
Assert.assertEquals("{\"@type\":\"dog\",\"dogName\":\"dog1001\"}", text);
Dog dog2 = (Dog) JSON.parseObject(text, Animal.class);
Assert.assertEquals(dog.dogName, dog2.dogName);Cat cat = new Cat();
cat.catName = "cat2001";
String text = JSON.toJSONString(cat, SerializerFeature.WriteClassName);
Assert.assertEquals("{\"@type\":\"cat\",\"catName\":\"cat2001\"}", text);
Cat cat2 = (Cat) JSON.parseObject(text, Animal.class);
Assert.assertEquals(cat.catName, cat2.catName);Jsontype Seealso En (`docs/jsontype_seealso_en.md`)
In Fastjson, you can use the JSONType#seeAlso annotation for configuration, which is similar to XmlSeeAlso in JAXB. The usage is as follows:
JavaBean Config
@JSONType(seeAlso={Dog.class, Cat.class})
public static class Animal {
}
@JSONType(typeName = "dog")
public static class Dog extends Animal {
public String dogName;
}
@JSONType(typeName = "cat")
public static class Cat extends Animal {
public String catName;
}Usage
Dog dog = new Dog();
dog.dogName = "dog1001";
String text = JSON.toJSONString(dog, SerializerFeature.WriteClassName);
Assert.assertEquals("{\"@type\":\"dog\",\"dogName\":\"dog1001\"}", text);
Dog dog2 = (Dog) JSON.parseObject(text, Animal.class);
Assert.assertEquals(dog.dogName, dog2.dogName);Cat cat = new Cat();
cat.catName = "cat2001";
String text = JSON.toJSONString(cat, SerializerFeature.WriteClassName);
Assert.assertEquals("{\"@type\":\"cat\",\"catName\":\"cat2001\"}", text);
Cat cat2 = (Cat) JSON.parseObject(text, Animal.class);
Assert.assertEquals(cat.catName, cat2.catName);Maven Deploy Guide (`docs/maven_deploy_guide.md`)
`FASTJSON2`发布操作说明
FASTJSON2发布到Maven中央库的操作过程/CheckList。
0. 前置准备与配置
在Maven的settting.xml中配置https://central.sonatype.com账号:
<servers>
<server>
<id>central</id>
<username>__YOUR_USERNAME__</username>
<password>__YOUR_PASSWORD__</password>
</server>
</servers>更多发布操作说明(如用于GPG签名的GPG安装与配置),参见:
- Maven Central Portal Getting Started
https://central.sonatype.org/publish/publish-portal-guide/ - Maven Central Portal Publishing By Using the Maven Plugin
https://central.sonatype.org/publish/publish-portal-maven/
发布过程与发布文件的查看地址:
- Maven Central Portal 的发布控制台
https://central.sonatype.com - Maven中央库的文件查看
https://repo1.maven.org/maven2/com/alibaba/fastjson2/
1. 发布操作
如果发布正式版本,先确认版本号,去掉
SNAPSHOT,如2.x.y。更新版本操作可以通过脚本
scripts/bump_fastjson2_version来统一完成。bashscripts/bump_fastjson2_version 2.x.y在工程根目录,执行发布
bash./mvnw clean && ./mvnw deploy -DperformRelease
Mixin Cn (`docs/mixin_cn.md`)
使用Mixin注入Annotation定制序列化和反序列化
当你需要定制化序列化一些LIB里面的类,你无法修改这些类的代码,你可以使用FASTJSON2的Mixin功能注入Annotation。
比如:
1. 要序列化的类
public static class Product {
public String name;
}2. 注入配置类
public abstract class ProductMixin {
@JSONField(name = "productName")
String name;
}3. 注入配置 & 使用
// 配置注入
JSON.mixIn(Product.class, ProductMixin.class);
// 使用
Product product = new Product();
product.name = "DataWorks";
assertEquals("{\"productName\":\"DataWorks\"}", JSON.toJSONString(product));
Product productParsed = JSON.parseObject("{\"productName\":\"DataWorks\"}", Product.class);
assertEquals("DataWorks", productParsed.name);4. 结合JSONCreator & JSONField(value=true)的例子
如下的Address类,没有缺省构造函数,只有一个字段,我希望序列化结果为address字段的字符串。
public static class Address {
private final String address;
public Address(String address) {
this.address = address;
}
public String getAddress() {
return address;
}
}注入使用方式如下:
static class AddressMixin {
// 通过JSONCreator指定构造函数
@JSONCreator
public AddressMixin(@JSONField(value = true) String address) {
}
// 配置输出使用此字段
@JSONField(value = true)
public String getAddress() {
return null;
}
}
@Test
public void test() {
JSON.mixIn(Address.class, AddressMixin.class); // 通过mixin注入Annotation
Address address = new Address("HangZhou");
// 序列化输出结果为address字段
String str = JSON.toJSONString(address);
assertEquals("\"HangZhou\"", str);
// 通过结果可以看出使用了JSONCreator指定的构造函数
Address address1 = JSON.parseObject(str, Address.class);
assertEquals(address.getAddress(), address1.getAddress());
}Mixin En (`docs/mixin_en.md`)
Using Mixin to Inject Annotations for Custom Serialization and Deserialization
When you need to customize the serialization of classes from a library whose code you cannot modify, you can use FASTJSON2's Mixin feature to inject annotations.
For example:
1. The Class to be Serialized
public static class Product {
public String name;
}2. The Mixin Configuration Class
public abstract class ProductMixin {
@JSONField(name = "productName")
String name;
}3. Injecting the Configuration & Usage
// Configure injection
JSON.mixIn(Product.class, ProductMixin.class);
// Usage
Product product = new Product();
product.name = "DataWorks";
assertEquals("{\"productName\":\"DataWorks\"}", JSON.toJSONString(product));
Product productParsed = JSON.parseObject("{\"productName\":\"DataWorks\"}", Product.class);
assertEquals("DataWorks", productParsed.name);4. Example with JSONCreator & JSONField(value=true)
Consider the following Address class, which has no default constructor and only one field. We want the serialization result to be the string value of the address field.
public static class Address {
private final String address;
public Address(String address) {
this.address = address;
}
public String getAddress() {
return address;
}
}The injection and usage are as follows:
static class AddressMixin {
// Specify the constructor with @JSONCreator
@JSONCreator
public AddressMixin(@JSONField(value = true) String address) {
}
// Configure the output to use this field
@JSONField(value = true)
public String getAddress() {
return null;
}
}
@Test
public void test() {
JSON.mixIn(Address.class, AddressMixin.class); // Inject annotations via mixin
Address address = new Address("HangZhou");
// The serialization output is the value of the address field
String str = JSON.toJSONString(address);
assertEquals("\"HangZhou\"", str);
// The result shows that the constructor specified by @JSONCreator was used
Address address1 = JSON.parseObject(str, Address.class);
assertEquals(address.getAddress(), address1.getAddress());
}Performance Cn (`docs/performance_cn.md`)
性能优化指南
FASTJSON 2 以极致性能为设计目标。本指南介绍调优策略和最佳实践,帮助您充分发挥库的性能。
性能架构
FASTJSON 2 通过以下关键优化实现高性能:
ASM 代码生成
FASTJSON 2 在运行时使用 ASM 为对象读取器和写入器生成优化的字节码,消除了字段访问和方法调用的反射开销。生成的代码使用基于字段名称哈希的 switch-case 语句,在反序列化时实现 O(1) 的字段查找。
- 时机: 首次序列化/反序列化某类型时(一次性开销)
- 实现:
ObjectReaderCreatorASM、ObjectWriterCreatorASM - 降级: 当 ASM 不可用时使用反射创建器(Android、GraalVM Native Image)
Lambda Metafactory
在 JDK 8+ 上,FASTJSON 2 使用 LambdaMetafactory 创建高性能方法句柄,作为反射的替代方案。这为 getter/setter 调用提供接近原生调用的性能。
Vector API(JDK 17+)
在 JDK 17+ 上,FASTJSON 2 利用 Vector API 的 SIMD(单指令多数据)指令进行 UTF-8 和 UTF-16 解析器中的批量字符处理。这极大地加速了字符串扫描和验证。
字符串驻留
SymbolTable 为频繁使用的字段名称提供高效的字符串驻留,减少解析过程中的内存分配和 GC 压力。
编码特化解析器
FASTJSON 2 为不同编码提供专用的解析器实现:
JSONReaderUTF8- 针对 UTF-8 字节流优化JSONReaderUTF16- 针对 UTF-16(Java String 内部表示)优化JSONReaderASCII- 纯 ASCII 内容的快速路径
库会根据输入类型自动检测最优解析器。
调优策略
1. 优先使用 byte[] 而非 String
影响: 高
尽量直接使用 byte[] 而非 String:
// 更快:从 bytes 解析
byte[] bytes = getJsonBytes(); // 来自网络、文件等
User user = JSON.parseObject(bytes, User.class);
// 更快:序列化为 bytes
byte[] output = JSON.toJSONBytes(user);这避免了 String 编码/解码的开销,在 HTTP/RPC 场景中尤其有效。
2. 内部通信使用 JSONB
影响: 非常高
对于服务间通信,JSONB(二进制 JSON)比文本 JSON 提供 3-9 倍的性能提升和更小的数据体积:
// 序列化
byte[] bytes = JSONB.toBytes(user);
// 反序列化
User user = JSONB.parseObject(bytes, User.class);
// 配合 BeanToArray 更快
byte[] bytes = JSONB.toBytes(user, JSONWriter.Feature.BeanToArray);
User user = JSONB.parseObject(bytes, User.class, JSONReader.Feature.SupportArrayToBean);3. 大文档使用 JSONPath 部分解析
影响: 高(针对大型文档)
当只需从大型 JSON 文档中获取特定字段时,使用 JSONPath 提取而无需解析整个文档:
// 缓存 JSONPath 实例(线程安全)
static final JSONPath ID_PATH = JSONPath.of("$.id");
static final JSONPath NAME_PATH = JSONPath.of("$.name");
// 提取特定字段
Object id = ID_PATH.extract(JSONReader.of(json));
Object name = NAME_PATH.extract(JSONReader.of(json));4. 使用 BeanToArray 紧凑序列化
影响: 中
BeanToArray Feature 将对象序列化为 JSON 数组而非对象,去除字段名开销:
// 输出: [1,"John",25] 而非 {"id":1,"name":"John","age":25}
String json = JSON.toJSONString(user, JSONWriter.Feature.BeanToArray);
User user = JSON.parseObject(json, User.class, JSONReader.Feature.SupportArrayToBean);5. 最小化 Feature 使用
影响: 低-中
每个启用的 Feature 在热路径中增加一个条件检查。仅启用实际需要的 Feature:
// 好:仅启用需要的
String json = JSON.toJSONString(user, JSONWriter.Feature.WriteNulls);
// 避免:启用很多"以防万一"的 Feature
String json = JSON.toJSONString(user,
JSONWriter.Feature.WriteNulls,
JSONWriter.Feature.PrettyFormat, // 不需要就跳过
JSONWriter.Feature.ReferenceDetection, // 没有循环引用就跳过
JSONWriter.Feature.MapSortField); // 不关心顺序就跳过6. 使用 FieldBased 获取最大速度
影响: 中
FieldBased 模式直接访问字段而非通过 getter/setter 方法,速度略快:
String json = JSON.toJSONString(user, JSONWriter.Feature.FieldBased);
User user = JSON.parseObject(json, User.class, JSONReader.Feature.FieldBased);注意:这通过反射/ASM 访问私有字段,可能在所有环境中都不可用。
7. 缓存自定义类型的 ObjectReader/ObjectWriter
影响: 中
如果注册了自定义 reader/writer,确保它们是单例:
// 好:单例模式
class MoneyWriter implements ObjectWriter<Money> {
static final MoneyWriter INSTANCE = new MoneyWriter();
// ...
}
JSON.register(Money.class, MoneyWriter.INSTANCE);线程安全
了解线程安全有助于避免不必要的同步:
| 组件 | 线程安全? | 说明 |
|---|---|---|
JSON 静态方法 |
是 | 主入口,始终安全 |
JSONObject / JSONArray |
否 | 未同步,类似 HashMap/ArrayList |
JSONReader / JSONWriter |
否 | 每次操作创建,不要跨线程共享 |
ObjectReader / ObjectWriter |
是 | 初始化后可安全共享 |
JSONPath |
是 | 可缓存并在线程间重复使用 |
ObjectReaderProvider / ObjectWriterProvider |
是 | 内部缓存是线程安全的 |
JVM 调优
推荐 JVM 参数
# 启用紧凑字符串(JDK 9+,默认开启)
-XX:+CompactStrings
# JDK 17+,启用 Vector API 孵化器模块
--add-modules jdk.incubator.vector内存注意事项
- FASTJSON 2 使用线程本地缓冲区进行序列化,减少 GC 压力但增加每线程内存占用。
- 对于多线程应用,请监控线程本地缓冲区使用情况。
- JSONB 通常比文本 JSON 使用更少的内存,因为编码更紧凑。
性能测试
FASTJSON 2 在 benchmark/ 模块中包含 JMH 基准测试。运行方式:
cd benchmark
mvn clean package
java -jar target/benchmarks.jar已发布的与 Jackson、Gson 等库的对比测试结果请参阅:
Performance En (`docs/performance_en.md`)
Performance Guide
FASTJSON 2 is designed for maximum performance. This guide covers tuning strategies and best practices to get the most out of the library.
Performance Architecture
FASTJSON 2 achieves its performance through several key optimizations:
ASM Code Generation
At runtime, FASTJSON 2 generates optimized bytecode for object readers and writers using ASM. This eliminates reflection overhead for field access and method invocation. The generated code uses switch-case statements on field name hashes for O(1) field lookup during deserialization.
- When: First time a type is serialized/deserialized (one-time cost)
- Where:
ObjectReaderCreatorASM,ObjectWriterCreatorASM - Fallback: Reflection-based creator when ASM is unavailable (Android, GraalVM Native Image)
Lambda Metafactory
On JDK 8+, FASTJSON 2 uses LambdaMetafactory to create high-performance method handles as an alternative to reflection. This provides near-native-call performance for getter/setter invocations.
Vector API (JDK 17+)
On JDK 17+, FASTJSON 2 leverages SIMD (Single Instruction, Multiple Data) instructions via the Vector API for bulk character processing in UTF-8 and UTF-16 parsers. This dramatically accelerates string scanning and validation.
String Interning
The SymbolTable provides efficient string interning for frequently used field names, reducing memory allocation and GC pressure during parsing.
Encoding-Specific Parsers
FASTJSON 2 has dedicated parser implementations for different encodings:
JSONReaderUTF8- optimized for UTF-8 byte streamsJSONReaderUTF16- optimized for UTF-16 (Java String internal representation)JSONReaderASCII- fast path for ASCII-only content
The library auto-detects the optimal parser based on input type.
Tuning Strategies
1. Prefer byte[] Over String
Impact: High
When possible, work with byte[] directly instead of String:
// Faster: parse from bytes
byte[] bytes = getJsonBytes(); // from network, file, etc.
User user = JSON.parseObject(bytes, User.class);
// Faster: serialize to bytes
byte[] output = JSON.toJSONBytes(user);This avoids the overhead of String encoding/decoding. It is especially effective for HTTP/RPC scenarios where data arrives as bytes.
2. Use JSONB for Internal Communication
Impact: Very High
For service-to-service communication, JSONB (binary JSON) provides 3-9x faster performance and smaller payload sizes compared to text JSON:
// Serialize
byte[] bytes = JSONB.toBytes(user);
// Deserialize
User user = JSONB.parseObject(bytes, User.class);
// Even faster with BeanToArray
byte[] bytes = JSONB.toBytes(user, JSONWriter.Feature.BeanToArray);
User user = JSONB.parseObject(bytes, User.class, JSONReader.Feature.SupportArrayToBean);3. Use JSONPath for Partial Parsing
Impact: High (for large documents)
When you only need specific fields from a large JSON document, use JSONPath to extract them without parsing the entire document:
// Cache the JSONPath instance (thread-safe)
static final JSONPath ID_PATH = JSONPath.of("$.id");
static final JSONPath NAME_PATH = JSONPath.of("$.name");
// Extract specific fields
Object id = ID_PATH.extract(JSONReader.of(json));
Object name = NAME_PATH.extract(JSONReader.of(json));4. Use BeanToArray for Compact Serialization
Impact: Medium
The BeanToArray feature serializes objects as JSON arrays instead of objects, removing field name overhead:
// Output: [1,"John",25] instead of {"id":1,"name":"John","age":25}
String json = JSON.toJSONString(user, JSONWriter.Feature.BeanToArray);
User user = JSON.parseObject(json, User.class, JSONReader.Feature.SupportArrayToBean);5. Minimize Feature Usage
Impact: Low-Medium
Each enabled Feature adds a condition check in the hot path. Only enable features you actually need:
// Good: only enable what you need
String json = JSON.toJSONString(user, JSONWriter.Feature.WriteNulls);
// Avoid: enabling many features "just in case"
String json = JSON.toJSONString(user,
JSONWriter.Feature.WriteNulls,
JSONWriter.Feature.PrettyFormat, // skip if not needed
JSONWriter.Feature.ReferenceDetection, // skip if no circular refs
JSONWriter.Feature.MapSortField); // skip if order doesn't matter6. Use FieldBased for Maximum Speed
Impact: Medium
FieldBased mode accesses fields directly instead of through getter/setter methods, which is slightly faster:
String json = JSON.toJSONString(user, JSONWriter.Feature.FieldBased);
User user = JSON.parseObject(json, User.class, JSONReader.Feature.FieldBased);Note: This accesses private fields via reflection/ASM, which may not work in all environments.
7. Cache ObjectReader/ObjectWriter for Custom Types
Impact: Medium
If you register custom readers/writers, ensure they are singletons:
// Good: singleton pattern
class MoneyWriter implements ObjectWriter<Money> {
static final MoneyWriter INSTANCE = new MoneyWriter();
// ...
}
JSON.register(Money.class, MoneyWriter.INSTANCE);Thread Safety
Understanding thread safety helps avoid unnecessary synchronization:
| Component | Thread-Safe? | Notes |
|---|---|---|
JSON static methods |
Yes | Main entry point, always safe |
JSONObject / JSONArray |
No | Not synchronized, like HashMap/ArrayList |
JSONReader / JSONWriter |
No | Create per-operation, never share across threads |
ObjectReader / ObjectWriter |
Yes | After initialization, safe to share |
JSONPath |
Yes | Cache and reuse across threads |
ObjectReaderProvider / ObjectWriterProvider |
Yes | Internal caching is thread-safe |
JVM Tuning
Recommended JVM Flags
# Enable compact strings (JDK 9+, on by default)
-XX:+CompactStrings
# For JDK 17+, enable Vector API incubator module
--add-modules jdk.incubator.vectorMemory Considerations
- FASTJSON 2 uses thread-local buffers for serialization, which reduces GC pressure but increases per-thread memory.
- For applications with many threads, monitor thread-local buffer usage.
- JSONB typically uses less memory than text JSON due to compact encoding.
Benchmarking
FASTJSON 2 includes JMH benchmarks in the benchmark/ module. To run:
cd benchmark
mvn clean package
java -jar target/benchmarks.jarFor published benchmark results comparing FASTJSON 2 with Jackson, Gson, and other libraries, see:
Projects Using (`docs/projects_using.md`)
如下收录了使用fastjson2的项目列表,收录的条件是github star数量>=100,如下:
- https://github.com/infowangxin/springboot-freemarker
- https://github.com/alibaba/canal
- https://github.com/alibaba/druid
- https://github.com/game-town/ioGame
- https://github.com/yangzongzhuan/RuoYi-Cloud
- https://github.com/yangzongzhuan/RuoYi-Vue-Oracle
- https://github.com/yangzongzhuan/RuoYi-Vue
- https://github.com/yangzongzhuan/RuoYi-Vue-fast
- https://github.com/matevip/matecloud
- https://github.com/wgzhao/Addax
- https://github.com/techa03/goodsKill
- https://github.com/whiteshader/React-Admin-Cloud
- https://github.com/vctgo/vctgo-platform
- https://github.com/wayn111/newbee-mall-pro
- https://github.com/alibaba/jetcache
- https://github.com/newbee-ltd/newbee-mall-plus
- https://github.com/apache/dubbo
- https://github.com/HHa1ey/TKHunter
- https://github.com/dromara/Sa-Token
- https://github.com/yangrunkang/upupor
- https://github.com/PomZWJ/database-export
- https://github.com/648540858/wvp-GB28181-pro
- https://github.com/TechEmpower/FrameworkBenchmarks
- https://github.com/wayn111/waynboot-mall
- https://github.com/PlexPt/chatgpt-java
- https://github.com/topiam/eiam
- https://github.com/martin-chips/DimpleBlog
- https://github.com/dromara/Jpom
- https://github.com/apache/dubbo-samples
- https://github.com/tony2y/RuoYi-flowable
- https://github.com/rstyro/Springboot
- https://github.com/shiyindaxiaojie/eden-architect
- https://github.com/86dbs/dbsyncer
- https://github.com/alibaba/easyexcel
- https://github.com/KrystianLi/ExchangeOWA
- https://github.com/alibaba/DataX
- https://github.com/entropy-cloud/nop-entropy
- https://github.com/C3Stones/blog
- https://github.com/bit4woo/reCAPTCHA
- https://github.com/mybatis-flex/mybatis-flex
- https://github.com/nageoffer/congomall
- https://github.com/qi4L/JYso
- https://github.com/chaitin/HummerRisk
- https://github.com/XiaoMi/mone
- https://github.com/cubefs/compass
- https://github.com/Ginyi3705/ginyi-spring-vue
- https://github.com/kylelin1998/ChatGPTForTelegram
- https://github.com/LuckyPuppy514/jproxy
- https://github.com/HamaWhiteGG/flink-sql-lineage
- https://github.com/HXSecurity/DongTai-agent-java
- https://github.com/Y4er/ysoserial
- https://github.com/alldatacenter/alldata
- https://github.com/alibaba/arthas
- https://github.com/asleepyfish/chatgpt
- https://github.com/libaibaia/cloudSec
- https://github.com/linyimin0812/spring-startup-analyzer
- https://github.com/zfile-dev/zfile
- https://github.com/noear/solon
- https://github.com/nageoffer/12306
- https://github.com/geekidea/spring-boot-plus
- https://github.com/tgscan-dev/tgscan
- https://github.com/chat2db/Chat2DB
- https://github.com/bihell/Dice
- https://github.com/oddfar/campus-imaotai
- https://github.com/OGtwelve/OGTwelveUtilPack
- https://github.com/mfish-qf/mfish-nocode
- https://github.com/pnoker/iot-dc3
- https://github.com/red-velet/qrpc
- https://github.com/smartloli/EFAK
- https://github.com/969025903/ChopperBot
- https://github.com/XiaoMi/mone
- https://github.com/gz-yami/mall4cloud
- https://github.com/cas-bigdatalab/piflow
- https://github.com/DataLinkDC/dinky
- https://github.com/wh1t3p1g/ysomap
- https://github.com/dromara/liteflow
- https://github.com/jar-analyzer/jar-analyzer
- https://github.com/wmsJackWang/jackdking-root
- https://github.com/spring-projects/spring-ai
- https://github.com/XiaoMi/ozhera
- https://github.com/rstyro/admin-plus
https://github.com/zfoo-project/zfoo - https://github.com/TongchengOpenSource/ckibana
- https://github.com/geekidea/spring-boot-plus
- https://github.com/02cx/dong-rpc
- https://github.com/smart-doc-group/smart-doc-example-cn
- https://github.com/shuanx/BurpFingerPrint
- https://github.com/sagframe/sagacity-sqltoy
- https://github.com/X1r0z/JNDIMap
- https://github.com/apache/rocketmq
- https://github.com/kerwincui/wumei-smart
- https://github.com/kerwincui/FastBee
- https://github.com/luguosong/programming-notes
- https://github.com/niumoo/JavaNotes
- https://github.com/OpenFeign/feign
- https://github.com/yl-yue/yue-library
- https://github.com/dromara/forest
- https://github.com/xunlu129/teriteri-backend
- https://github.com/moshowgame/SpringBootCodeGenerator
- https://github.com/4379711/lol-helper
- https://github.com/zddgg/novel-cast
- https://github.com/Whoopsunix/PPPYSO
- https://github.com/wangzihaogithub/spring-boot-protocol
- https://github.com/woodwhales/woodwhales-music
- https://github.com/JanesenGit/FastChar
- https://github.com/tokyohost/v2nodeManager
- https://github.com/giteecode/hospitalRegistePublic
- https://github.com/wujun728/jun_java_plugin
- https://github.com/anhan123456/vrpc
- https://github.com/spring-projects/spring-ai
- https://github.com/wujun728/jun_java_plugin
- https://github.com/Alanosy/online-exam-system-backend
- https://github.com/zcode-zjw/zcode-commons
- https://github.com/WeBankFinTech/Exchangis
- https://github.com/Harries/springboot-demo
- https://github.com/642933588/jiron-cloud
- https://github.com/cool-team-official/cool-admin-java
- https://github.com/akto-api-security/akto
- https://github.com/Devo919/Gewechat
- https://github.com/KouShenhai/KCloud-Platform-IoT
- https://github.com/starmcc/qs-beanfun
- https://github.com/Shleter587/aippt_PresentationGen
- https://github.com/dromara/warm-flow
- https://github.com/lich0821/WeChatFerry
- https://github.com/winezer0/APIFinderPlus
- https://github.com/aws/aws-lambda-java-libs
- https://github.com/Joolun/JooLun-wx
- https://github.com/apache/incubator-seata
- https://github.com/jd-opensource/joylive-agent
- https://github.com/mapleplus/feng-shortlink
- https://github.com/yindz/common-random
- https://github.com/alibaba/termd
- https://github.com/CodePhiliaX/fastexcel
- https://github.com/Zy-Fang1102/E-Stega
- https://github.com/Dev0ke/angr-java
- https://github.com/aliyun/alibabacloud-microservice-demo
- https://github.com/javagossip/dorado
- https://github.com/xuxueli/xxl-rpc
- https://github.com/ww20081120/framework
- https://github.com/burukeYou/UniHttp
- https://github.com/xuxueli/xxl-conf
- https://github.com/B0T1eR/ysoSimple
- https://github.com/elunez/eladmin
- https://github.com/elunez/eladmin-mp
- https://github.com/LinQi0777/RiskEngine
- https://github.com/niujt/Hospital
- https://github.com/xbatis/xbatis
- https://github.com/ageerle/ruoyi-ai
- https://github.com/javifalces/HFTFramework
- https://github.com/insmess/insmess-meeting-manager
- https://github.com/zhihuili/flower
- https://github.com/MikuNyanya/RabbitBot_RE
- https://github.com/yuyan-sec/druid_sessions
- https://github.com/javagossip/opendsp
- https://github.com/shaiwz/data-platform-open
- https://github.com/818000/bus
- https://github.com/houbb/sensitive-word-admin
- https://github.com/Auties00/Cobalt
- https://github.com/newVkDing2/coinc
- https://github.com/Romantic-Lei/Learning-in-practice
- https://github.com/xiaou61/U-space
- https://github.com/qiantongtech/qData
- https://github.com/qiantongtech/qKnow
- https://github.com/zuihou/lamp-util
- https://github.com/dromara/lamp-cloud
- https://github.com/KouShenhai/KCloud-Platform-IoT
- https://github.com/alibaba/spring-ai-alibaba
- https://github.com/alibaba/QLExpress
Reader Codegen Cn (`docs/reader_codegen_cn.md`)
反序列化CodeGen算法介绍
fastjson2会使用codegen来优化反序列化的性能,用到的codegen技术包括:
- ASM 基于内置asm 9.2裁剪版实现的动态字节码生成类
- Annotation Process Tools(APT)
1. 实现算法介绍
上图中算法1是常规实现;算法2是fastjson2的实现(最初是dsljson引入,被fastjson借鉴);算法3是新引入的实现
我们要将json反序列化为如下的Image类
@Data
public class Image {
private int height;
private Size size;
private String title;
private String uri;
private int width;
}生成如下的代码来快速将json中的name和字段关联起来:
/* Detailed source-code truncated for AI context efficiency. */相关方法在JSONReader中的实现
class JSONReaderUTF8 implements JSONReader {
public final int getRawInt() {
if (offset + 3 < bytes.length) {
return UNSAFE.getInt(bytes, ARRAY_BYTE_BASE_OFFSET + offset - 1);
}
return 0;
}
public boolean nextIfName4Match3() {
offset += 5;
if (bytes[offset - 2] != '"' || bytes[offset - 1] != ':') {
return false;
}
// ...
return true;
}
public final boolean nextIfName4Match4(byte c4) {
offset += 6;
if (bytes[offset - 3] != c4 || bytes[offset - 2] != '"' || bytes[offset - 1] != ':') {
return false;
}
// ...
return true;
}
public boolean nextIfName4Match5(int name1) {
offset += 7;
if (UNSAFE.getInt(bytes, ARRAY_BYTE_BASE_OFFSET + offset - 4) != name1) {
return false;
}
// ...
return true;
}
public boolean nextIfName4Match6(int name1) {
offset += 8;
if (UNSAFE.getInt(bytes, ARRAY_BYTE_BASE_OFFSET + offset - 5) != name1 || bytes[offset - 1] != ':') {
return false;
}
// ...
return true;
}
}这样的实现好处是,不需要将key读取出来,也不需要将使用JSONReader#readFieldNameHashCode,通过key的前缀3个字符读取一个int值,使用switch来路由到相应字段的处理。
2. 算法实现代码
生成代码的实现:
- ASM实现 com.alibaba.fastjson2.reader.ObjectReaderCreatorASM#genRead243
- APT实现 com.alibaba.fastjson2.internal.processor.JSONCompiledAnnotationProcessor.genRead243
Reader Codegen En (`docs/reader_codegen_en.md`)
Introduction to the Deserialization CodeGen Algorithm
fastjson2 uses codegen to optimize deserialization performance. The codegen techniques used include:
- ASM: Dynamic bytecode class generation based on a built-in, trimmed version of ASM 9.2.
- Annotation Processing Tools (APT)
1. Introduction to the Implementation Algorithm
In the diagram above, Algorithm 1 is a conventional implementation; Algorithm 2 is fastjson2's implementation (originally introduced by dsljson and adopted by fastjson); Algorithm 3 is a newly introduced implementation.
We want to deserialize a JSON into the following Image class:
@Data
public class Image {
private int height;
private Size size;
private String title;
private String uri;
private int width;
}The following code is generated to quickly associate the names in the JSON with the fields:
/* Detailed source-code truncated for AI context efficiency. */The implementation of the related methods in JSONReader is as follows:
class JSONReaderUTF8 implements JSONReader {
public final int getRawInt() {
if (offset + 3 < bytes.length) {
return UNSAFE.getInt(bytes, ARRAY_BYTE_BASE_OFFSET + offset - 1);
}
return 0;
}
public boolean nextIfName4Match3() {
offset += 5;
if (bytes[offset - 2] != '"' || bytes[offset - 1] != ':') {
return false;
}
// ...
return true;
}
public final boolean nextIfName4Match4(byte c4) {
offset += 6;
if (bytes[offset - 3] != c4 || bytes[offset - 2] != '"' || bytes[offset - 1] != ':') {
return false;
}
// ...
return true;
}
public boolean nextIfName4Match5(int name1) {
offset += 7;
if (UNSAFE.getInt(bytes, ARRAY_BYTE_BASE_OFFSET + offset - 4) != name1) {
return false;
}
// ...
return true;
}
public boolean nextIfName4Match6(int name1) {
offset += 8;
if (UNSAFE.getInt(bytes, ARRAY_BYTE_BASE_OFFSET + offset - 5) != name1 || bytes[offset - 1] != ':') {
return false;
}
// ...
return true;
}
}The advantage of this implementation is that it doesn't need to read the entire key, nor does it need to use JSONReader#readFieldNameHashCode. Instead, it reads an integer value from the first few bytes of the key and uses a switch statement to route to the corresponding field's processing logic.
2. Algorithm Implementation Code
Code Generation Implementation:
- ASM Implementation:
com.alibaba.fastjson2.reader.ObjectReaderCreatorASM#genRead243 - APT Implementation:
com.alibaba.fastjson2.internal.processor.JSONCompiledAnnotationProcessor.genRead243
Register Custom Reader Writer Cn (`docs/register_custom_reader_writer_cn.md`)
实现ObjectWriter和ObjectReader实现定制序列化和反序列化
1. 实现ObjectWriter接口定制化序列化
1.1 ObjectWriter的定义
package com.alibaba.fastjson2.writer;
public interface ObjectWriter<T> {
void write(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features);
}1.2 实现ObjectWriter举例
class InetAddressWriter implements ObjectWriter {
InetAddressWriter INSTANCE = new InetAddressWriter();
@Override
public void write(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features) {
if (object == null) {
jsonWriter.writeNull();
return;
}
InetAddress address = (InetAddress) object;
// 优先使用name
jsonWriter.writeString(address.getHostName());
}
}1.3 注册Writer
JSON.register(InetAddress.class, InetAddressWriter.INSTANCE);
JSON.register(Inet4Address.class, InetAddressWriter.INSTANCE);
JSON.register(Inet6Address.class, InetAddressWriter.INSTANCE);1.4 注册ObjectWriters的一些内置实现
ObjectWriters提供了构造ofToString/ofToInt/ofToLong方法,让使用者能更方便序列化,比如:
public static class Bean {
public int id;
public String toString() {
return Integer.toString(id);
}
public int getId() {
return id;
}
}
@Test
public void testToString() {
ObjectWriter objectWriter = ObjectWriters.ofToString(Bean::toString);
Bean bean = new Bean();
bean.id = 101;
JSONWriter jsonWriter = JSONWriter.of();
objectWriter.write(jsonWriter, bean);
assertEquals("\"101\"", jsonWriter.toString());
}
@Test
public void testToInt() {
ObjectWriter<Bean> objectWriter = ObjectWriters.ofToInt(
(ToIntFunction<Bean>) Bean::getId
);
Bean bean = new Bean();
bean.id = 101;
JSONWriter jsonWriter = JSONWriter.of();
objectWriter.write(jsonWriter, bean);
assertEquals("101", jsonWriter.toString());
}2. 实现ObjectReader定制反序列化
2.1 ObjectReader的定义
package com.alibaba.fastjson2.reader;
public interface ObjectReader<T> {
T readObject(JSONReader jsonReader, Type fieldType, Object fieldName, long features);
}ObjectReader还有很多其他方法,但都提供了缺省实现,上面这个方法是必须实现的。
2.2 实现ObjectReader举例
import java.time.Instant;
import com.alibaba.fastjson2.reader.ObjectReader;
class InstantReader implements ObjectReader {
public static final InstantReader INSTANCE = new InstantReader();
@Override
public Object readObject(JSONReader jsonReader, Type fieldType, Object fieldName, long features) {
if (jsonReader.nextIfNull()) {
return null;
}
long millis = jsonReader.readInt64Value();
return Instant.ofEpochMilli(millis);
}
}2.3 注册Reader
JSON.register(Instant.class, InstantReader.INSTANCE);2.4 注册内置的ObjectReaders提供的一些内置实现
ObjectReaders提供了构造ofString/ofInt/ofLong方法,让使用者能更方便反序列化,比如:
public static class Bean {
final int code;
public Bean(String str) {
code = Integer.parseInt(str);
}
}
@Test
public void test() {
JSON.register(Bean.class, ObjectReaders.ofString(Bean::new));
Bean bean = JSON.parseObject("\"123\"", Bean.class);
assertEquals(123, bean.code);
}Register Custom Reader Writer En (`docs/register_custom_reader_writer_en.md`)
Implementing ObjectWriter and ObjectReader for Custom Serialization and Deserialization
1. Implementing the ObjectWriter Interface for Custom Serialization
1.1 ObjectWriter Definition
package com.alibaba.fastjson2.writer;
public interface ObjectWriter<T> {
void write(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features);
}1.2 ObjectWriter Implementation Example
class InetAddressWriter implements ObjectWriter {
static final InetAddressWriter INSTANCE = new InetAddressWriter();
@Override
public void write(JSONWriter jsonWriter, Object object, Object fieldName, Type fieldType, long features) {
if (object == null) {
jsonWriter.writeNull();
return;
}
InetAddress address = (InetAddress) object;
// Prioritize using the name
jsonWriter.writeString(address.getHostName());
}
}1.3 Registering the Writer
JSON.register(InetAddress.class, InetAddressWriter.INSTANCE);
JSON.register(Inet4Address.class, InetAddressWriter.INSTANCE);
JSON.register(Inet6Address.class, InetAddressWriter.INSTANCE);1.4 Registering Some Built-in Implementations of ObjectWriters
ObjectWriters provides ofToString/ofToInt/ofToLong methods to make serialization more convenient for users, for example:
public static class Bean {
public int id;
public String toString() {
return Integer.toString(id);
}
public int getId() {
return id;
}
}
@Test
public void testToString() {
ObjectWriter objectWriter = ObjectWriters.ofToString(Bean::toString);
Bean bean = new Bean();
bean.id = 101;
JSONWriter jsonWriter = JSONWriter.of();
objectWriter.write(jsonWriter, bean);
assertEquals("\"101\"", jsonWriter.toString());
}
@Test
public void testToInt() {
ObjectWriter<Bean> objectWriter = ObjectWriters.ofToInt(
(ToIntFunction<Bean>) Bean::getId
);
Bean bean = new Bean();
bean.id = 101;
JSONWriter jsonWriter = JSONWriter.of();
objectWriter.write(jsonWriter, bean);
assertEquals("101", jsonWriter.toString());
}2. Implementing ObjectReader for Custom Deserialization
2.1 ObjectReader Definition
package com.alibaba.fastjson2.reader;
public interface ObjectReader<T> {
T readObject(JSONReader jsonReader, Type fieldType, Object fieldName, long features);
}ObjectReader has many other methods, but they all provide default implementations. The method above must be implemented.
2.2 ObjectReader Implementation Example
import java.time.Instant;
import com.alibaba.fastjson2.reader.ObjectReader;
class InstantReader implements ObjectReader {
public static final InstantReader INSTANCE = new InstantReader();
@Override
public Object readObject(JSONReader jsonReader, Type fieldType, Object fieldName, long features) {
if (jsonReader.nextIfNull()) {
return null;
}
long millis = jsonReader.readInt64Value();
return Instant.ofEpochMilli(millis);
}
}2.3 Registering the Reader
JSON.register(Instant.class, InstantReader.INSTANCE);2.4 Registering Some Built-in Implementations Provided by ObjectReaders
ObjectReaders provides ofString/ofInt/ofLong methods to make deserialization more convenient for users, for example:
public static class Bean {
final int code;
public Bean(String str) {
code = Integer.parseInt(str);
}
}
@Test
public void test() {
JSON.register(Bean.class, ObjectReaders.ofString(Bean::new));
Bean bean = JSON.parseObject("\"123\"", Bean.class);
assertEquals(123, bean.code);
}Vector Optimized Cn (`docs/vector_optimized_cn.md`)
JDK 17中提供了vector api,可以用SIMD来优化性能。
fastjson 2.0.61版本开始全面使用SWAR(SIMD within a register)来做SIMD优化,不再需要使用vector api.
Vector Optimized En (`docs/vector_optimized_en.md`)
JDK 17 introduced the vector api, which can use SIMD to optimize performance.
Starting from version 2.0.61, fastjson2 comprehensively uses SWAR (SIMD within a register) for SIMD optimization and no longer needs to use the vector api.
Android Android Benchmark Cn (`docs/Android/android_benchmark_cn.md`)
1. SerDe Benchmark
执行10000次的耗时,数字越小越好。
| 手机型号 | library | eishay-ser | eishay-deser |
|---|---|---|---|
| Huawei Mate40 Pro | fastjson2 | 104 | 115 |
| fastjson1 | 69 | 109 | |
| jackson | 154 | 196 | |
| gson | 411 | 183 |
2. Parse Benchmark
执行1000次的耗时,数字越小越好。
| 手机型号 ˚ | library | eishay | cart | homepage | h5api |
|---|---|---|---|---|---|
| Huawei Mate40 Pro | fastjson2 | 34 | 3556 | 1411 | 3252 |
| fastjson1 | 79 | 3699 | 1621 | 3330 | |
| orgjson | 53 | 5238 | 1924 | 4400 |
Android Android Benchmark En (`docs/Android/android_benchmark_en.md`)
1. SerDe Benchmark
The time required to execute 10000 times, the smaller the number, the better.
| 手机型号 | library | eishay-ser | eishay-deser |
|---|---|---|---|
| Huawei Mate40 Pro | fastjson2 | 104 | 115 |
| fastjson1 | 69 | 109 | |
| jackson | 154 | 196 | |
| gson | 411 | 183 |
2. Parse Benchmark
The time required to execute 10000 times, the smaller the number, the better.
| 手机型号 ˚ | library | eishay | cart | homepage | h5api |
|---|---|---|---|---|---|
| Huawei Mate40 Pro | fastjson2 | 34 | 3556 | 1411 | 3252 |
| fastjson1 | 79 | 3699 | 1621 | 3330 | |
| orgjson | 53 | 5238 | 1924 | 4400 |
Filter Index Cn (`docs/Filter/index_cn.md`)
仅在序列化(将 Java 对象转换为 JSON 字符串)时生效:
- AfterFilter: 在序列化输出的末尾添加额外内容。
- BeforeFilter: 在序列化输出的开头添加额外内容。
- NameFilter: 用于在序列化时修改属性的名称。
- ContextNameFilter: 功能同
NameFilter,但它可以结合上下文信息修改属性名称。 - ValueFilter: 用于在序列化时修改属性的值。
- ContextValueFilter: 功能同
ValueFilter,但它可以结合上下文信息修改属性值。 - LabelFilter: 允许根据不同的场景标签(Label)来定制序列化输出不同的字段。
- PascalNameFilter: 这是一个
NameFilter的具体实现,它会将属性名称的首字母大写,实现驼峰命名到帕斯卡命名(Pascal)的转换。 - PropertyPreFilter: 根据属性名进行快速过滤,决定某个属性是否需要被序列化。
- PropertyFilter: 根据属性名和属性值来判断某个属性是否需要被序列化。
- SimplePropertyPreFilter: 一个简便的属性预过滤器,通过指定包含(includes)或排除(excludes)的属性列表来控制哪些字段参与序列化。
仅在反序列化(将 JSON 字符串转换为 Java 对象)时生效:
- ExtraProcessor: 用于处理在反序列化时,JSON 字符串中存在但 Java 对象中不存在的多余字段。
- AutoTypeBeforeHandler: 在 Fastjson 2.x 中,用于在反序列化时提供类似
AutoType功能,通过白名单机制来控制允许反序列化的类,以增强安全性。 - ContextAutoTypeBeforeHandler: 同样用于处理
AutoType,并提供了上下文信息,内置了一些常用的类型支持。
Filter Index En (`docs/Filter/index_en.md`)
Effective only during serialization (converting Java objects to JSON strings):
- AfterFilter: Adds extra content to the end of the serialized output.
- BeforeFilter: Adds extra content at the beginning of the serialized output.
- NameFilter: Used to modify property names during serialization.
- ContextNameFilter: Same function as
NameFilter, but it can modify property names using contextual information. - ValueFilter: Used to modify property values during serialization.
- ContextValueFilter: Same function as
ValueFilter, but it can modify property values using contextual information. - LabelFilter: Allows customizing the serialization of different fields based on different scenario labels (Label).
- PascalNameFilter: This is a specific implementation of
NameFilterthat capitalizes the first letter of property names, converting from camelCase to PascalCase. - PropertyPreFilter: Performs fast filtering based on the property name to decide whether a property should be serialized.
- PropertyFilter: Determines whether a property should be serialized based on its name and value.
- SimplePropertyPreFilter: A simple property pre-filter that controls which fields are serialized by specifying lists of included or excluded properties.
Effective only during deserialization (converting JSON strings to Java objects):
- ExtraProcessor: Used to handle extra fields that exist in the JSON string but not in the Java object during deserialization.
- AutoTypeBeforeHandler: In Fastjson 2.x, it provides
AutoType-like functionality during deserialization, using a whitelist mechanism to control which classes are allowed to be deserialized, thus enhancing security. - ContextAutoTypeBeforeHandler: Also used to handle
AutoType, but provides contextual information and has built-in support for some common types.
Filter Name Filter Cn (`docs/Filter/name_filter_cn.md`)
NameFilter
FASTJSON提供了一个序列化时对字段名做处理的扩展叫做NameFilter,接口如下
package com.alibaba.fastjson2.filter;
public interface NameFilter
extends Filter {
String process(Object object, String name, Object value);
}NameFilter通过of方法提供了常见需求的实现,比如:
public class Bean {
public int userId;
}
@Test
public void test() {
Bean bean = new Bean();
bean.userId = 101;
NameFilter pascalNameFilter = NameFilter.of(PropertyNamingStrategy.PascalCase);
String str = JSON.toJSONString(bean, pascalNameFilter);
assertEquals("{\"UserId\":101}", str);
JSONObject object = JSON.parseObject(str);
assertEquals(101, object.get("UserId"));
}Filter Name Filter En (`docs/Filter/name_filter_en.md`)
NameFilter
FASTJSON provides an extension for processing field names during serialization called NameFilter. The interface is as follows:
package com.alibaba.fastjson2.filter;
public interface NameFilter
extends Filter {
String process(Object object, String name, Object value);
}NameFilter provides implementations for common requirements through the of method, for example:
public class Bean {
public int userId;
}
@Test
public void test() {
Bean bean = new Bean();
bean.userId = 101;
NameFilter pascalNameFilter = NameFilter.of(PropertyNamingStrategy.PascalCase);
String str = JSON.toJSONString(bean, pascalNameFilter);
assertEquals("{\"UserId\":101}", str);
JSONObject object = JSON.parseObject(str);
assertEquals(101, object.get("UserId"));
}Filter Value Filter Cn (`docs/Filter/value_filter_cn.md`)
ValueFilter
FASTJSON提供了一个序列化时对字段名做处理的扩展叫做ValueFilter,接口如下
package com.alibaba.fastjson2.filter;
public interface ValueFilter
extends Filter {
Object apply(Object object, String name, Object value);
}ValueFilter允许你在输出的时候自定义输出的值,比如:
public static class Bean {
public int id;
}
@Test
public void test_valuefilterCompose() {
ValueFilter filter0 = (source, name, value) -> {
if ("id".equals(name)) {
return ((Integer) value).intValue() + 1;
}
return value;
};
ValueFilter filter1 = (source, name, value) -> {
if ("id".equals(name)) {
return ((Integer) value).intValue() + 10;
}
return value;
};
Bean bean = new Bean();
bean.id = 100;
String str = JSON.toJSONString(bean, ValueFilter.compose(filter0, filter1));
assertEquals("{\"id\":111}", str);
}Filter Value Filter En (`docs/Filter/value_filter_en.md`)
ValueFilter
FASTJSON provides an extension for processing field values during serialization called Value-Filter. The interface is as follows:
package com.alibaba.fastjson2.filter;
public interface ValueFilter
extends Filter {
Object apply(Object object, String name, Object value);
}ValueFilter allows you to customize the output value during serialization, for example:
public static class Bean {
public int id;
}
@Test
public void test_valuefilterCompose() {
ValueFilter filter0 = (source, name, value) -> {
if ("id".equals(name)) {
return ((Integer) value).intValue() + 1;
}
return value;
};
ValueFilter filter1 = (source, name, value) -> {
if ("id".equals(name)) {
return ((Integer) value).intValue() + 10;
}
return value;
};
Bean bean = new Bean();
bean.id = 100;
String str = JSON.toJSONString(bean, ValueFilter.compose(filter0, filter1));
assertEquals("{\"id\":111}", str);
}JSONB Jsonb Format Cn (`docs/JSONB/jsonb_format_cn.md`)
JSONB存储格式设计
1. 设计目标
- 和JSON格式对应,能完全表示JSON
- 紧凑,数据不留空洞
- 对常用整数-16~63做紧凑设计
- 对null/true/false做紧凑设计
- 对0~15长度的ARRAY 做紧凑设计
- 对0~47长度的ascii编码的字符串做紧凑设计
- 对OBJECT类型的Name做短编码的支持
- 支持完整的Java序列化和反序列化
2. JSON支持格式定义
/* Detailed source-code truncated for AI context efficiency. */3. 数值表示设计
jsonb支持的数值类型:
- INT8
- INT16
- INT32
- INT64
- BIGINT
- DECIMAL
- FLOAT
- DOUBLE
数值的表示在连续的区间,范围是0xb2 ~ 0x48
3.1 INT32设计
INT32的表示在不同取值范围所需要的字节数不一样
| 取值范围 | 所需要字节数 |
|---|---|
| -16 ~ 47 | 1 |
| -2048 ~ 2047 | 2 |
| -262144 ~ 262143 | 3 |
| -2147483648 ~ 2147483647 | 5 |
* 0xf0 ~ 0x2f 直接表示-16 ~ 47的INT32整数,只需要1个字节,也不需要额外转换
* 0x30 ~ 0x3f 表示-2048 ~ 2047的INT32整数,需要使用2个字节
* 0x40 ~ 0x47 表示-262144 ~ 262143的,需要使用3个字节
* 0x48 + <bytes4>,第1个byte是0x48,之后4个byte表示数值,需要使用5个字节3.2 INT64设计
| 取值范围 | 所需要字节数 |
|---|---|
| -8 ~ 15 | 1 |
| -2048 ~ 2047 | 2 |
| -262144 ~ 262143 | 3 |
| -2147483648 ~ 2147483647 | 5 |
| 0x8000000000000000L ~ 0x7fffffffffffffffL | 9 |
* 0xd8 ~ 0xef 直接表示-8 ~ 15的INT64整数,只需要1个字节
* 0xc8 ~ 0xd7 表示-2048 ~ 2047的INT64整数,需要使用2个字节
* 0xc0 ~ 0xc7 表示-262144 ~ 262143的INT64整数,需要使用3个字节
* 0xbf + <bytes4>,第1个byte是0xbf,之后4个byte表示数值,需要使用5个字节
* 0xbe + <bytes8>,第1个byte是0xbe,之后8个byte表示数值,需要使用9个字节3.3 INT8 & INT16
* 0xbd + <bytes1> 表示IN8,需要2个字节
* 0xbc + <bytes2> 表示IN16,需要3个字节3.4 BIGINT表示设计
BIGINT有两种表示法:
* 0xba + <int64> ,当BIGINT的取值范围在0x8000000000000000L ~ 0x7fffffffffffffffL时,在int64之前加一个0xba的字节,所需要的字节数是2 ~ 10。
* 0xbb + <bytes_len> + <bytes>3.5 DECIMAL表示法
DECIMAL有两种表示法
* 0xb8 + <int64>,当没有小数,并且 取值范围在0x8000000000000000L ~ 0x7fffffffffffffffL时,在int64之前加一个0xb8的字节,所需要的字节数是2 ~ 10。
* 0xb9 + <scale_int32> + <int32|int64|bigint>3.6 FLOAT表示
FLOAT有两种表示法
* 0xb6 + <int32> 没有小数的FLOAT,所需要字节数2 ~ 6个
* 0xb7 + <bytes4> 需要5个字节3.7 DOUBLE表示
DOUBLE有三种表示
* 0xb2 ~ 0xb3 表示0和1,占1个字节
* 0xb4 + <int64> 没有小数的double,所需要2~10个字节
* 0xb5 + <bytes8> 需要9个bytes4. NULL/TRUE/FALSE
NULL/TRUE/FALSE都使用1个字节表示
- 0xaf NULL
- 0xb0 FALSE
- 0xb1 TRUE
5. 字符串表示
字符串的表示有三种办法:
* 0x49 ~ 0x78 表示长度为0 ~ 47的LATIN1字符串
* 0x79 + <int32_bytes_len> + <bytes> LATIN1字符串
* 0x7a + <int32_bytes_len> + <bytes> UTF8字符串
* 0x7b + <int32_bytes_len> + <bytes> UTF16字符串
* 0x7c + <int32_bytes_len> + <bytes> UTF16LE字符串
* 0x7d + <int32_bytes_len> + <bytes> UTF16BE字符串
* 0x7e + <int32_bytes_len> + <bytes> GB18030编码字符串(这个可以减少中文编码的长度)
* 0x7f + <int32_symbol> 如果symbol为负数,则是SymbolTable中的下标。如果是>=0,则是当前数据中字符串符号字符串专门设计对了LATIN1编码字符的支持。这个对字符串的反序列化性能提升会很有帮助,对Java 9+之后的字符串序列化也会有帮助。
6. 日期表示
* 0xae + <int64_epoch_second> + <int32_nano> TIMESTAMP 需要3~15个字节,对应java中的Instant类型
* 0xad + <bytes4_epoch_minutes> TIMESTAMP_MINUTES 需要5个字节,对应java中的Date类型
* 0xac + <bytes4_epoch_seconds> TIMESTAMP_SECONDS 需要5个字节,对应java中的Date类型
* 0xab + <bytes8_epoch_millis> TIMESTAMP_MILLIS 需要9个字节,对应java中的Date类型
* 0xaa + <bytes2_year> + <bytes1_monthValue> + <bytes1_dayOfMonth> + <bytes1_hour> + <bytes1_minute> + <bytes1_second> + <int32_nano> + <str_zoneId>,对应java中ZonedDateTime
* 0xa9 + <bytes2_year> + <bytes1_monthValue> + <bytes1_dayOfMonth> 需要5个字节,对应java中的LocalDate类型
* 0xa8 + <bytes2_year> + <bytes1_monthValue> + <bytes1_dayOfMonth> + <bytes1_hour> + <bytes1_minute> + <bytes1_second> + <int32_nano> 需要8~12个字符,对应java中的LocalDateTime类型
* 0xa7 + <bytes1_hour> + <bytes1_minute> + <bytes1_second> + <int32_nano> 需要4~8个字符,对应java中的LocalTime类型7. 对象类型
对象类型以0xa6开始,0xa5结束,中间有若干个key_value对,如下:
0xa6
[<key_any> <value_any>]...
0xa58. 数组类型
数组有两种表示法
* 0x94 ~ 0xa3表示元素个数为0~15的数组
* 0xa4 + <int32_length> + <item...>9. Reference
* 0x93 + <str_reference_path>10. Typed_Any
这个类型可以使得支持完整地序列化和反序列化
* 0x92 + <str_typename> + <any>11. 二进制类型
0x91 + <int32_length> + <bytes>12. char类型
0x90 <byte1>JSONB Jsonb Format En (`docs/JSONB/jsonb_format_en.md`)
Design of JSONB Storage Format
1. Design Goals
- To be compatible with the JSON format and capable of fully representing JSON.
- Compact, with no data gaps.
- Compact design for commonly used integers from -16 to 63.
- Compact design for null/true/false.
- Compact design for ARRAYs of length 0 to 15.
- Compact design for ASCII-encoded strings of length 0 to 47.
- Support for short encoding of OBJECT names (keys).
- Support for complete Java serialization and deserialization.
2. JSON Support Format Definition
/* Detailed source-code truncated for AI context efficiency. */3. Numeric Representation Design
JSONB supports the following numeric types:
- INT8
- INT16
- INT32
- INT64
- BIGINT
- DECIMAL
- FLOAT
- DOUBLE
The representation of numeric values is in a contiguous range from 0xb2 to 0x48.
3.1 INT32 Design
The number of bytes required to represent an INT32 varies depending on its value range.
| Value Range | Bytes Required |
|---|---|
| -16 ~ 47 | 1 |
| -2048 ~ 2047 | 2 |
| -262144 ~ 262143 | 3 |
| -2147483648 ~ 2147483647 | 5 |
* 0xf0 ~ 0x2f: Directly represents INT32 integers from -16 to 47, requiring only 1 byte without extra conversion.
* 0x30 ~ 0x3f: Represents INT32 integers from -2048 to 2047, requiring 2 bytes.
* 0x40 ~ 0x47: Represents INT32 integers from -262144 to 262143, requiring 3 bytes.
* 0x48 + <4_bytes>: The first byte is 0x48, followed by 4 bytes representing the value, requiring 5 bytes in total.3.2 INT64 Design
| Value Range | Bytes Required |
|---|---|
| -8 ~ 15 | 1 |
| -2048 ~ 2047 | 2 |
| -262144 ~ 262143 | 3 |
| -2147483648 ~ 2147483647 | 5 |
| 0x8000000000000000L ~ 0x7fffffffffffffffL | 9 |
* 0xd8 ~ 0xef: Directly represents INT64 integers from -8 to 15, requiring only 1 byte.
* 0xc8 ~ 0xd7: Represents INT64 integers from -2048 to 2047, requiring 2 bytes.
* 0xc0 ~ 0xc7: Represents INT64 integers from -262144 to 262143, requiring 3 bytes.
* 0xbf + <4_bytes>: The first byte is 0xbf, followed by 4 bytes representing the value, requiring 5 bytes in total.
* 0xbe + <8_bytes>: The first byte is 0xbe, followed by 8 bytes representing the value, requiring 9 bytes in total.3.3 INT8 & INT16
* 0xbd + <1_byte>: Represents INT8, requires 2 bytes.
* 0xbc + <2_bytes>: Represents INT16, requires 3 bytes.3.4 BIGINT Representation Design
BIGINT has two representations:
* 0xba + <int64>: When the BIGINT's value is within the range 0x8000000000000000L ~ 0x7fffffffffffffffL, it is prefixed with a 0xba byte, requiring 2 to 10 bytes.
* 0xbb + <bytes_len> + <bytes>3.5 DECIMAL Representation
DECIMAL has two representations:
* 0xb8 + <int64>: When there is no fractional part and the value is within the range 0x8000000000000000L ~ 0x7fffffffffffffffL, it is prefixed with a 0xb8 byte, requiring 2 to 10 bytes.
* 0xb9 + <scale_int32> + <int32|int64|bigint>3.6 FLOAT Representation
FLOAT has two representations:
* 0xb6 + <int32>: Represents a FLOAT without a fractional part, requiring 2 to 6 bytes.
* 0xb7 + <4_bytes>: Requires 5 bytes.3.7 DOUBLE Representation
DOUBLE has three representations:
* 0xb2 ~ 0xb3: Represents 0 and 1, occupying 1 byte.
* 0xb4 + <int64>: Represents a double without a fractional part, requiring 2 to 10 bytes.
* 0xb5 + <8_bytes>: Requires 9 bytes.4. NULL/TRUE/FALSE
NULL/TRUE/FALSE are each represented by a single byte:
- 0xaf NULL
- 0xb0 FALSE
- 0xb1 TRUE
5. String Representation
There are several ways to represent strings:
* 0x49 ~ 0x78: Represents a LATIN1 string with a length of 0 to 47.
* 0x79 + <int32_bytes_len> + <bytes>: LATIN1 string.
* 0x7a + <int32_bytes_len> + <bytes>: UTF8 string.
* 0x7b + <int32_bytes_len> + <bytes>: UTF16 string.
* 0x7c + <int32_bytes_len> + <bytes>: UTF16LE string.
* 0x7d + <int32_bytes_len> + <bytes>: UTF16BE string.
* 0x7e + <int32_bytes_len> + <bytes>: GB18030 encoded string (this can reduce the length for Chinese characters).
* 0x7f + <int32_symbol>: If the symbol is negative, it is an index into the SymbolTable. If it is >= 0, it is a string symbol within the current data.The string format is specifically designed to support LATIN1 encoded characters. This will be very helpful for improving string deserialization performance and will also benefit string serialization in Java 9+.
6. Date Representation
* 0xae + <int64_epoch_second> + <int32_nano>: TIMESTAMP, requires 3 to 15 bytes, corresponds to Java's Instant type.
* 0xad + <4_bytes_epoch_minutes>: TIMESTAMP_MINUTES, requires 5 bytes, corresponds to Java's Date type.
* 0xac + <4_bytes_epoch_seconds>: TIMESTAMP_SECONDS, requires 5 bytes, corresponds to Java's Date type.
* 0xab + <8_bytes_epoch_millis>: TIMESTAMP_MILLIS, requires 9 bytes, corresponds to Java's Date type.
* 0xaa + <2_bytes_year> + <1_byte_monthValue> + <1_byte_dayOfMonth> + <1_byte_hour> + <1_byte_minute> + <1_byte_second> + <int32_nano> + <str_zoneId>: Corresponds to Java's ZonedDateTime.
* 0xa9 + <2_bytes_year> + <1_byte_monthValue> + <1_byte_dayOfMonth>: Requires 5 bytes, corresponds to Java's LocalDate type.
* 0xa8 + <2_bytes_year> + <1_byte_monthValue> + <1_byte_dayOfMonth> + <1_byte_hour> + <1_byte_minute> + <1_byte_second> + <int32_nano>: Requires 8 to 12 bytes, corresponds to Java's LocalDateTime type.
* 0xa7 + <1_byte_hour> + <1_byte_minute> + <1_byte_second> + <int32_nano>: Requires 4 to 8 bytes, corresponds to Java's LocalTime type.7. Object Type
An object type starts with 0xa6 and ends with 0xa5, containing any number of key-value pairs in between, as follows:
0xa6
[<key_any> <value_any>]...
0xa58. Array Type
An array has two representations:
* 0x94 ~ 0xa3: Represents an array with 0 to 15 elements.
* 0xa4 + <int32_length> + <item...>9. Reference
* 0x93 + <str_reference_path>10. Typed_Any
This type enables complete serialization and deserialization.
* 0x92 + <str_typename> + <any>11. Binary Type
0x91 + <int32_length> + <bytes>12. char type
0x90 <byte1>JSONB Jsonb Size Compare Cn (`docs/JSONB/jsonb_size_compare_cn.md`)
带类型信息 KeyValue映射
| size | ||
|---|---|---|
| jsonb | 409 | 使用WriteClassName |
| hessian | 644 | |
| fury | 670 | 配置CompatibleMode.COMPATIBLE |
| java serialize | 1123 |
不带类型信息 KeyValue映射
对象使用KeyValue的方式映射,这种方式的好处是增加和删除字段不影响兼容性
| size | ||
|---|---|---|
| json | 451 | |
| jsonb | 348 |
不带类型信息 Array映射
对象使用数组的方式映射,这种方式对增加/删除字段会影响兼容性
| size | ||
|---|---|---|
| json | 276 | 配置BeanToArray |
| jsonb | 223 | 配置BeanToArray |
| protobuf-3 | 235 |
JSONB Jsonb Size Compare En (`docs/JSONB/jsonb_size_compare_en.md`)
Key-Value Mapping with Type Information
| size | ||
|---|---|---|
| jsonb | 409 | Using WriteClassName |
| hessian | 644 | |
| fury | 670 | Configured with CompatibleMode.COMPATIBLE |
| java serialize | 1123 |
Key-Value Mapping without Type Information
Objects are mapped using a Key-Value approach. The advantage of this method is that adding and deleting fields does not affect compatibility.
| size | ||
|---|---|---|
| json | 451 | |
| jsonb | 348 |
Array Mapping without Type Information
Objects are mapped using an array approach. This method's compatibility is affected by adding or deleting fields.
| size | ||
|---|---|---|
| json | 276 | Configured with BeanToArray |
| jsonb | 223 | Configured with BeanToArray |
| protobuf-3 | 235 |
JSONB Jsonb Vs Hessian Kryo Cn (`docs/JSONB/jsonb_vs_hessian_kryo_cn.md`)
Int32整数处理
- 这三种协议都采用了整数压缩的算法,kryo的压缩效果最好,实际使用中大小会比较接近。
- jsonb和hessian的大小是一样的。
- jsonb在size为1的期间[-6, 47]的二进制的值和数值一致,是为调试时的可读性更好考虑。
| jsonb | hessian | kryo | |
|---|---|---|---|
| 1 | [-16, 47] | [-16, 47] | [-64, 63] |
| 2 | [-2048, -17] [48, 2047] | [-2048, -17] [48, 2047] | [-8192, -65] [64, 8191] |
| 3 | [-262144, -2049] [2048, 262143] | [-262144, -2049] [2048, 262143] | [-1048576, -8193] [8192, 1048575] |
| 4 | [-134217728, -1048577] [1048576, 134217727] | ||
| 5 | [-2147483648, -262145] [262144, 2147483647] | [-2147483648, -262145] [262144, 2147483647] | [-2147483648, -134217729] [134217727, 2147483647] |
JSONB Jsonb Vs Hessian Kryo En (`docs/JSONB/jsonb_vs_hessian_kryo_en.md`)
Int32 Integer Handling
- All three protocols use integer compression algorithms. Kryo's compression is the most effective, but their sizes will be quite similar in actual use.
- jsonb and hessian have the same size.
- For jsonb, in the size-1 range of [-16, 47], the binary value is consistent with the numeric value, which is designed for better readability during debugging.
| jsonb | hessian | kryo | |
|---|---|---|---|
| 1 | [-16, 47] | [-16, 47] | [-64, 63] |
| 2 | [-2048, -17] [48, 2047] | [-2048, -17] [48, 2047] | [-8192, -65] [64, 8191] |
| 3 | [-262144, -2049] [2048, 262143] | [-262144, -2049] [2048, 262143] | [-1048576, -8193] [8192, 1048575] |
| 4 | [-134217728, -1048577] [1048576, 134217727] | ||
| 5 | [-2147483648, -262145] [262144, 2147483647] | [-2147483648, -262145] [262144, 2147483647] | [-2147483648, -134217729] [134217727, 2147483647] |
JSONPath Jsonpath Benchmark Cn (`docs/JSONPath/jsonpath_benchmark_cn.md`)
fastjson2将 JSONPath 作为一等公民,针对jsonpath做了很多优化。
结论
在如下测试场景中,fastjson2的性能是jayway的4.5倍
- 测试代码:JSONPathPerf.java
测试数据
Benchmark Mode Cnt Score Error Units
JSONPathPerf.fastjsonReaderAuthors thrpt 5 1260.479 ± 46.356 ops/ms
JSONPathPerf.jaywayReadAuthors thrpt 5 276.301 ± 2.447 ops/msJSONPath Jsonpath Benchmark En (`docs/JSONPath/jsonpath_benchmark_en.md`)
fastjson2 treats JSONPath as a first-class citizen and has made many optimizations for it.
Conclusion
In the test scenario below, fastjson2's performance is 4.5 times that of jayway.
- Test code: JSONPathPerf.java
Test Data
Benchmark Mode Cnt Score Error Units
JSONPathPerf.fastjsonReaderAuthors thrpt 5 1260.479 ± 46.356 ops/ms
JSONPathPerf.jaywayReadAuthors thrpt 5 276.301 ± 2.447 ops/msJSONPath Jsonpath Cn (`docs/JSONPath/jsonpath_cn.md`)
FASTJSON2 JSONPath支持介绍
在FASTJSON2中,JSONPath是一等公民,支持通过JSONPath在不完整解析JSON Document的情况下,根据JSONPath读取内容;也支持用JSONPath对JavaBean求值,可以在Java框架中当做对象查询语言(OQL)来使用。
语法兼容标准
支持SQL 2016的JSON Path的语法 ISO/IEC 19075-6
1. 支持语法
| JSONPATH | 描述 |
|---|---|
| $ | 根对象,例如$.name |
| [num] | 数组访问,其中num是数字,可以是负数。例如$[0].leader.departments[-1].name |
| [num0,num1,num2...] | 数组多个元素访问,其中num是数字,可以是负数,返回数组中的多个元素。例如$[0,3,-2,5] |
| [start:end] | 数组范围访问,其中start和end是开始小表和结束下标,可以是负数,返回数组中的多个元素。例如$[0:5] |
| [start:end :step] | 数组范围访问,其中start和end是开始小表和结束下标,可以是负数;step是步长,返回数组中的多个元素。例如$[0:5:2] |
| [?(@.key)] | 对象属性非空过滤,例如$.departs[?(@.name)] |
| [?(@.key > 123)] | 数值类型对象属性比较过滤,例如$.departs[id >= 123],比较操作符支持=,!=,>,>=,<,<= |
| [?(@.key = '123')] | 字符串类型对象属性比较过滤,例如$.departs[?(@..name = '123')],比较操作符支持=,!=,>,>=,<,<= |
| [?(@.key like 'aa%')] | 字符串类型like过滤, 例如$.departs[?(@..name like 'sz*')],通配符只支持%支持not like |
| [?(@.key rlike 'regexpr')] | 字符串类型正则匹配过滤, |
| [?(@.key in ('v0', 'v1'))] | IN过滤, 支持字符串和数值类型 例如: $.departs[?(@.name in ('wenshao','Yako'))] $.departs[id not in (101,102)] |
| [?(@.key between 234 and 456)] | BETWEEN过滤, 支持数值类型,支持not between 例如: $.departs[?(@.id between 101 and 201)] $.departs[?(@.id not between 101 and 201)] |
| length() 或者 size() | 数组长度。例如$.values.size() 支持类型java.util.Map和java.util.Collection和数组 |
| . | 属性访问,例如$.name |
| .. | deepScan属性访问,例如$..name |
| * | 对象的所有属性,例如$.leader.* |
| ['key'] | 属性访问。例如$['name'] |
| ['key0','key1'] | 多个属性访问。例如$['id','name'] |
以下两种写法的语义是相同的:
$.store.book[0].title和
$['store']['book'][0]['title']1.1 函数
| Function | 返回类型 | Description |
|---|---|---|
| type | string | 返回对象的类型 |
| length/size | integer | 返回集合或者字符串的长度 |
| first | Any | 集合中第一个元素 |
| last | Any | 集合中最后一个元素 |
| values | sequence | Map类型的Values |
| entries | sequence | Map类型的EntrySet |
| trim | string | 对字符串做trim后返回 |
| double | double | 将目标类型转换为double类型 |
| ceil | number | 对数值类型做ceil处理返回 |
| abs | number | 返回对数值类型的绝对值 |
| lower | string | 将字符串转换小写 |
| upper | string | 将字符串转换成大写 |
| index(x) | int | 其中参数x支持数值和字符串 |
1.2 聚合函数
| Function | 返回类型 | Description |
|---|---|---|
| min | ||
| max | ||
| first | 返回集合中的第一个元素 | |
| last | 返回集合中的最后一个个元素 | |
| avg | double |
1.3 Filter Operators
| Operator | Description |
|---|---|
| = | 相等 |
| != or <> | 不等 |
| > | 大于 |
| >= | 大于等于 |
| < | 小于 |
| <= | 小于等于 |
| ~= | |
| like | 类似SQL中LIKE语法 |
| not like | |
| rlike | |
| not rlike | |
| in | |
| not in | |
| between | |
| not between | |
| starts_with | |
| not starts_with | |
| ends_with | |
| not ends_with | |
| contains | |
| not contains |
2. 语法举例
| JSONPath | 语义 |
|---|---|
| $ | 根对象 |
| $[-1] | 最后元素 |
| $[:-2] | 第1个至倒数第2个 |
| $[1:] | 第2个之后所有元素 |
| $[1,2,3] | 集合中1,2,3个元素 |
3. API 示例
3.1 例1
public void test_entity() throws Exception {
Entity entity = new Entity(123, new Object());
assertSame(entity.getValue(), JSONPath.eval(entity, "$.value"));
assertTrue(JSONPath.contains(entity, "$.value"));
assertEquals(2, JSONPath.eval(entity, "$.length()"));
assertEquals(0, JSONPath.eval(new Object[0], "$.length()"));
}
public static class Entity {
private Integer id;
private String name;
private Object value;
public Entity() {}
public Entity(Integer id, Object value) { this.id = id; this.value = value; }
public Entity(Integer id, String name) { this.id = id; this.name = name; }
public Entity(String name) { this.name = name; }
public Integer getId() { return id; }
public Object getValue() { return value; }
public String getName() { return name; }
public void setId(Integer id) { this.id = id; }
public void setName(String name) { this.name = name; }
public void setValue(Object value) { this.value = value; }
}3.2 例2
读取集合多个元素的某个属性
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity("wenshao"));
entities.add(new Entity("ljw2083"));
List<String> names = (List<String>)JSONPath.eval(entities, "$.name"); // 返回enties的所有名称
assertSame(entities.get(0).getName(), names.get(0));
assertSame(entities.get(1).getName(), names.get(1));3.3 例3
返回集合中多个元素
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity("wenshao"));
entities.add(new Entity("ljw2083"));
entities.add(new Entity("Yako"));
List<Entity> result = (List<Entity>)JSONPath.eval(entities, "[1,2]"); // 返回下标为1和2的元素
assertEquals(2, result.size());
assertSame(entities.get(1), result.get(0));
assertSame(entities.get(2), result.get(1));3.4 例4
按范围返回集合的子集
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity("wenshao"));
entities.add(new Entity("ljw2083"));
entities.add(new Entity("Yako"));
List<Entity> result = (List<Entity>)JSONPath.eval(entities, "[0:2]"); // 返回下标从0到2的元素
assertEquals(3, result.size());
assertSame(entities.get(0), result.get(0));
assertSame(entities.get(1), result.get(1));
assertSame(entities.get(2), result.get(2));3.5 例5
通过条件过滤,返回集合的子集
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
entities.add(new Entity(1003, "yakolee"));
entities.add(new Entity(1004, null));
List<Object> result = (List<Object>) JSONPath.eval(entities, "[?(@.id in (1001))]");
assertEquals(1, result.size());
assertSame(entities.get(0), result.get(0));3.6 例6
根据属性值过滤条件判断是否返回对象,修改对象,数组属性添加元素
Entity entity = new Entity(1001, "ljw2083");
assertSame(entity , JSONPath.eval(entity, "[?(@.id = 1001)]"));
JSONPath.set(entity, "id", 123456); //将id字段修改为123456
assertEquals(123456, entity.getId().intValue());
JSONPath.set(entity, "value", new int[0]); //将value字段赋值为长度为0的数组3.7 例7
Map root = Collections.singletonMap("company",
Collections.singletonMap("departs",
Arrays.asList(
Collections.singletonMap("id", 1001),
Collections.singletonMap("id", 1002),
Collections.singletonMap("id", 1003)
)
));
List<Object> ids = (List<Object>) JSONPath.eval(root, "$..id");
assertEquals(3, ids.size());
assertEquals(1001, ids.get(0));
assertEquals(1002, ids.get(1));
assertEquals(1003, ids.get(2));JSONPath Jsonpath En (`docs/JSONPath/jsonpath_en.md`)
Introduction to FASTJSON2 JSONPath Support
In FASTJSON2, JSONPath is a first-class citizen. It supports reading content via JSONPath without fully parsing the entire JSON Document. It also supports evaluating JSONPath against JavaBeans, allowing it to be used as an Object Query Language (OQL) within Java frameworks.
Syntax Compatibility Standard
Compatible with the JSON Path syntax of SQL 2016 ISO/IEC 19075-6
1. Supported Syntax
| JSONPATH | Description |
|---|---|
| $ | Root object, e.g., $.name |
| [num] | Array access, where num is a number and can be negative. e.g., $.leader.departments[-1].name |
| [num0,num1,num2...] | Multiple array element access, where num is a number and can be negative, returning multiple elements from the array. e.g., $[0,3,-2,5] |
| [start:end] | Array slice access, where start and end are the starting and ending indices and can be negative, returning multiple elements from the array. e.g., $[0:5] |
| [start:end :step] | Array slice access with a step, where start and end are the starting and ending indices (can be negative), and step is the increment. e.g., $[0:5:2] |
| [?(@.key)] | Object property non-null filter, e.g., $.departs[?(@.name)] |
| [?(@.key > 123)] | Numeric object property comparison filter, e.g., $.departs[id >= 123]. Comparison operators supported: =, !=, >, >=, <, <= |
| [?(@.key = '123')] | String object property comparison filter, e.g., $.departs[?(@..name = '123')]. Comparison operators supported: =, !=, >, >=, <, <= |
| [?(@.key like 'aa%')] | String 'like' filter, e.g., $.departs[?(@..name like 'sz*')]. Only the '%' wildcard is supported. not like is also supported. |
| [?(@.key rlike 'regexpr')] | String regular expression match filter, |
| [?(@.key in ('v0', 'v1'))] | IN filter, supports string and numeric types. e.g., $.departs[?(@.name in ('wenshao','Yako'))] or $.departs[id not in (101,102)] |
| [?(@.key between 234 and 456)] | BETWEEN filter, supports numeric types. not between is also supported. e.g., $.departs[?(@.id between 101 and 201)] $.departs[?(@.id not between 101 and 201)] |
| length() or size() | Array length. e.g., $.values.size(). Supports java.util.Map, java.util.Collection, and arrays. |
| . | Property access, e.g., $.name |
| .. | Deep scan property access, e.g., $..name |
| * | All properties of an object, e.g., $.leader.* |
| ['key'] | Property access. e.g., $['name'] |
| ['key0','key1'] | Multiple property access. e.g., $['id','name'] |
The following two syntaxes have the same meaning:
$.store.book[0].titleand
$['store']['book'][0]['title']1.1 Functions
| Function | Return Type | Description |
|---|---|---|
| type | string | Returns the type of the object |
| length/size | integer | Returns the length of a collection or string |
| first | Any | The first element in a collection |
| last | Any | The last element in a collection |
| values | sequence | The values() of a Map type |
| entries | sequence | The entrySet() of a Map type |
| trim | string | Returns the trimmed string |
| double | double | Converts the target type to a double |
| ceil | number | Returns the ceiling of a numeric value |
| abs | number | Returns the absolute value of a numeric value |
| lower | string | Converts a string to lower case |
| upper | string | Converts a string to upper case |
| index(x) | int | The parameter x can be a number or a string |
1.2 Aggregate Functions
| Function | Return Type | Description |
|---|---|---|
| min | ||
| max | ||
| first | Returns the first element of the collection | |
| last | Returns the last element of the collection | |
| avg | double |
1.3 Filter Operators
| Operator | Description |
|---|---|
| = | Equal |
| != or <> | Not equal |
| > | Greater than |
| >= | Greater than or equal to |
| < | Less than |
| <= | Less than or equal to |
| ~= | |
| like | Similar to LIKE in SQL |
| not like | |
| rlike | |
| not rlike | |
| in | |
| not in | |
| between | |
| not between | |
| starts_with | |
| not starts_with | |
| ends_with | |
| not ends_with | |
| contains | |
| not contains |
2. Syntax Examples
| JSONPath | Meaning |
|---|---|
| $ | Root object |
| $[-1] | Last element |
| $[:-2] | First to the second to last element |
| $[1:] | All elements from the second one on |
| $[1,2,3] | The 1st, 2nd, and 3rd elements in the collection |
3. API Examples
3.1 Example 1
public void test_entity() throws Exception {
Entity entity = new Entity(123, new Object());
assertSame(entity.getValue(), JSONPath.eval(entity, "$.value"));
assertTrue(JSONPath.contains(entity, "$.value"));
assertEquals(2, JSONPath.eval(entity, "$.length()"));
assertEquals(0, JSONPath.eval(new Object[0], "$.length()"));
}
public static class Entity {
private Integer id;
private String name;
private Object value;
public Entity() {}
public Entity(Integer id, Object value) { this.id = id; this.value = value; }
public Entity(Integer id, String name) { this.id = id; this.name = name; }
public Entity(String name) { this.name = name; }
public Integer getId() { return id; }
public Object getValue() { return value; }
public String getName() { return name; }
public void setId(Integer id) { this.id = id; }
public void setName(String name) { this.name = name; }
public void setValue(Object value) { this.value = value; }
}3.2 Example 2
Read a specific property from multiple elements in a collection.
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity("wenshao"));
entities.add(new Entity("ljw2083"));
List<String> names = (List<String>)JSONPath.eval(entities, "$.name"); // returns all names from the entities
assertSame(entities.get(0).getName(), names.get(0));
assertSame(entities.get(1).getName(), names.get(1));3.3 Example 3
Return multiple elements from a collection.
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity("wenshao"));
entities.add(new Entity("ljw2083"));
entities.add(new Entity("Yako"));
List<Entity> result = (List<Entity>)JSONPath.eval(entities, "[1,2]"); // returns elements at index 1 and 2
assertEquals(2, result.size());
assertSame(entities.get(1), result.get(0));
assertSame(entities.get(2), result.get(1));3.4 Example 4
Return a subset of a collection by range.
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity("wenshao"));
entities.add(new Entity("ljw2083"));
entities.add(new Entity("Yako"));
List<Entity> result = (List<Entity>)JSONPath.eval(entities, "[0:2]"); // returns elements from index 0 to 2 (inclusive)
assertEquals(3, result.size());
assertSame(entities.get(0), result.get(0));
assertSame(entities.get(1), result.get(1));
assertSame(entities.get(2), result.get(2));3.5 Example 5
Return a subset of a collection by filtering with a condition.
List<Entity> entities = new ArrayList<Entity>();
entities.add(new Entity(1001, "ljw2083"));
entities.add(new Entity(1002, "wenshao"));
entities.add(new Entity(1003, "yakolee"));
entities.add(new Entity(1004, null));
List<Object> result = (List<Object>) JSONPath.eval(entities, "[?(@.id in (1001))]");
assertEquals(1, result.size());
assertSame(entities.get(0), result.get(0));3.6 Example 6
Filter object based on property value, modify object, and add an element to an array property.
Entity entity = new Entity(1001, "ljw2083");
assertSame(entity , JSONPath.eval(entity, "[?(@.id = 1001)]"));
JSONPath.set(entity, "id", 123456); // Set the id field to 123456
assertEquals(123456, entity.getId().intValue());
JSONPath.set(entity, "value", new int[0]); // Set the value field to an empty array3.7 Example 7
Map root = Collections.singletonMap("company",
Collections.singletonMap("departs",
Arrays.asList(
Collections.singletonMap("id", 1001),
Collections.singletonMap("id", 1002),
Collections.singletonMap("id", 1003)
)
));
List<Object> ids = (List<Object>) JSONPath.eval(root, "$..id");
assertEquals(3, ids.size());
assertEquals(1001, ids.get(0));
assertEquals(1002, ids.get(1));
assertEquals(1003, ids.get(2));JSONPath Jsonpath Multi Cn (`docs/JSONPath/jsonpath_multi_cn.md`)
对同一个JSON做多个JSONPath求值的场景,FASTJSON2提供了专门的API,能提升性能,如下:
public class JSONPath {
public static JSONPath of(String[] paths, Type[] types) {
return of(paths, types, null, null);
}
public static JSONPath of(
String[] paths,
Type[] types,
String[] formats,
ZoneId zoneId,
JSONReader.Feature... features
);
}这样构造的JSONPath,在eval或者extract方法执行时,会返回和types类型匹配的对象数组。
JSONObject object = JSONObject.of("id", 1001, "name", "DataWorks", "date", "2017-07-14");
JSONPath jsonPath = JSONPath.of(
new String[]{"$.id", "$.name", "$.date"},
new Type[]{Long.class, String.class, Date.class}
);
Object[] expected = new Object[]{1001L, "DataWorks", DateUtils.parseDate("2017-07-14")};
Object[] evalResult = (Object[]) jsonPath.eval(object);
assertArrayEquals(expected, evalResult);
String jsonStr = object.toString();
Object[] result = (Object[]) jsonPath.extract(jsonStr);
assertArrayEquals(expected, result);JSONPath Jsonpath Multi En (`docs/JSONPath/jsonpath_multi_en.md`)
For scenarios where multiple JSONPath expressions are evaluated on the same JSON, FASTJSON2 provides a specialized API that can improve performance, as shown below:
public class JSONPath {
public static JSONPath of(String[] paths, Type[] types) {
return of(paths, types, null, null);
}
public static JSONPath of(
String[] paths,
Type[] types,
String[] formats,
ZoneId zoneId,
JSONReader.Feature... features
);
}A JSONPath object constructed in this way will return an array of objects matching the specified types when the eval or extract methods are executed.
JSONObject object = JSONObject.of("id", 1001, "name", "DataWorks", "date", "2017-07-14");
JSONPath jsonPath = JSONPath.of(
new String[]{"$.id", "$.name", "$.date"},
new Type[]{Long.class, String.class, Date.class}
);
Object[] expected = new Object[]{1001L, "DataWorks", DateUtils.parseDate("2017-07-14")};
Object[] evalResult = (Object[]) jsonPath.eval(object);
assertArrayEquals(expected, evalResult);
String jsonStr = object.toString();
Object[] result = (Object[]) jsonPath.extract(jsonStr);
assertArrayEquals(expected, result);JSONPath Jsonpath Typed Cn (`docs/JSONPath/jsonpath_typed_cn.md`)
在大数据场景下,我们会对JSONPath要求返回指定的类型,这个时候,JSONPath可以提供指定类型来返回,这样更高效,也更安全。
1. 接口定义
public class JSONPath {
public static JSONPath of(String path, Type type);
}2. 例子
String str = "{\"id\":1001, \"name\":\"DataWorks\"}";
JSONPath jsonPath = JSONPath.of("id", Long.class);
Long expected = 1001L;
assertEquals(expected, jsonPath.extract(json));JSONPath Jsonpath Typed En (`docs/JSONPath/jsonpath_typed_en.md`)
In big data scenarios, we often need JSONPath to return a specific type. JSONPath allows specifying a return type, which is more efficient and safer.
1. Interface Definition
public class JSONPath {
public static JSONPath of(String path, Type type);
}2. Example
String str = "{\"id\":1001, \"name\":\"DataWorks\"}";
JSONPath jsonPath = JSONPath.of("id", Long.class);
Long expected = 1001L;
assertEquals(expected, jsonPath.extract(str));JSONSchema Json Schema Cn (`docs/JSONSchema/json_schema_cn.md`)
FASTJSON v2 JSONSchema的支持
在fastjson 2.0.4版本之后,提供了JSONSchema的支持,具体JSON Schema的规范,参考 https://json-schema.org/
1. FASTJSON2 JSONSchema的性能
一贯如此,FASTJSON2 JSONSchema性能非常出色,远超竞品。如下的测试表名,fastjson2性能是networknt的9倍,everit的6倍。
Benchmark Mode Cnt Score Error Units
JSONSchemaBenchmark.everit thrpt 5 3.182 ± 0.018 ops/ms
JSONSchemaBenchmark.fastjson2 thrpt 5 21.408 ± 0.147 ops/ms
JSONSchemaBenchmark.networknt thrpt 5 2.337 ± 0.007 ops/ms2. 通过构造JSONSchema对象直接校验
@Test
public void test() {
// 定义必须包含longitude和latitude两个属性,其中longitude的取值范围是[-180 ~ 180],latitude的取值范围是[-90, 90]
JSONSchema schema = JSONSchema.of(JSON.parseObject("{" +
" \"type\": \"object\"," +
" \"properties\": {" +
" \"longitude\": { \"type\": \"number\", \"minimum\":-180, \"maximum\":180}," +
" \"latitude\": { \"type\": \"number\", \"minimum\":-90, \"maximum\":90}," +
" }," +
" \"required\": [\"longitude\", \"latitude\"]" +
"}"));
// 校验JSONObject对象,校验通过
assertTrue(
schema.isValid(
JSONObject.of("longitude", 120.1552, "latitude", 30.2741)
)
);
// 校验JSONObject失败,longitude超过最大值
assertFalse(
schema.isValid(
JSONObject.of("longitude", 220.1552, "latitude", 30.2741)
)
);
// 校验JavaBean对象,校验通过
assertTrue(
schema.isValid(
new Point(120.1552, 30.2741)
)
);
// 校验JavaBean对象,校验失败,latitude超过最大值
assertFalse(
schema.isValid(
new Point(120.1552, 130.2741)
)
);
}
public static class Point {
public final double longitude;
public final double latitude;
public Point(double longitude, double latitude) {
this.longitude = longitude;
this.latitude = latitude;
}
}3. 在JSONField上配置schema
2.0.4版本后,可以在Annotation JSONField上配置schema校验输入的json数据
public static class Point1 {
@JSONField(schema = "{'minimum':-180,'maximum':180}")
public double longitude;
@JSONField(schema = "{'minimum':-90,'maximum':90}")
public double latitude;
}
@Test
public void test1() {
// parseObject 校验通过
JSON.parseObject("{\"longitude\":120.1552,\"latitude\":30.2741}", Point1.class);
// JSONObject to JavaObject,校验通过
JSONObject.of("longitude", 120.1552, "latitude", 30.2741)
.to(Point1.class);
// parseObject 校验失败,longitude超过最大值
assertThrows(JSONSchemaValidException.class, () ->
JSON.parseObject("{\"longitude\":220.1552,\"latitude\":30.2741}", Point1.class)
);
// 校验JSONObject失败,longitude超过最大值
assertThrows(JSONSchemaValidException.class, () ->
JSONObject.of("longitude", 220.1552, "latitude", 30.2741)
.to(Point1.class)
);
}4. 在JSONType上配置schema
2.0.4版本后,可以在Annotation JSONType上配置schema校验输入的json数据
@JSONType(schema = "{'properties':{'longitude':{'type':'number','minimum':-180,'maximum':180},'latitude':{'type':'number','minimum':-90,'maximum':90}}}")
public static class Point2 {
@JSONField(schema = "{'minimum':-180,'maximum':180}")
public double longitude;
@JSONField(schema = "{'minimum':-90,'maximum':90}")
public double latitude;
}
@Test
public void test2() {
// parseObject 校验通过
JSON.parseObject("{\"longitude\":120.1552,\"latitude\":30.2741}", Point2.class);
// JSONObject to JavaObject,校验通过
JSONObject.of("longitude", 120.1552, "latitude", 30.2741)
.to(Point2.class);
// parseObject 校验失败,longitude超过最大值
assertThrows(JSONSchemaValidException.class, () ->
JSON.parseObject("{\"longitude\":220.1552,\"latitude\":30.2741}", Point2.class)
);
// 校验JSONObject失败,longitude超过最大值
assertThrows(JSONSchemaValidException.class, () ->
JSONObject.of("longitude", 220.1552, "latitude", 30.2741)
.to(Point2.class)
);
}5. 通过类型构造JSONSchema
在后端和前端交互时,需要将java类型转换成JSONSchema返回给客户端。
@Test
public void test() {
JSONSchema schema = JSONSchema.of(Bean.class);
String string = schema.toString();
assertEquals(
"{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"integer\"},\"name\":{\"type\":\"string\"}},\"required\":[\"id\"]}",
string
);
JSONSchema pased = JSONSchema.of(JSON.parseObject(string));
assertTrue(Differ.diff(schema, pased));
Bean bean = new Bean();
JSONSchema valueSchema = JSONSchema.ofValue(bean);
assertTrue(Differ.diff(schema, valueSchema));
}
public static class Bean {
public int id;
public String name;
}6. 通过值对象构造JSONSchema
@Test
public void fromValueMap() {
Map map = new HashMap();
map.put("id", 123);
assertEquals("{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"integer\"}}}", JSONSchema.ofValue(map).toString());
}JSONSchema Json Schema En (`docs/JSONSchema/json_schema_en.md`)
FASTJSON v2 JSONSchema Support
Since version 2.0.4, fastjson has provided support for JSONSchema. For the specific JSON Schema specification, please refer to https://json-schema.org/
1. Performance of FASTJSON2 JSONSchema
As always, the performance of FASTJSON2 JSONSchema is excellent, far surpassing its competitors. As the following test results show, fastjson2's performance is 9 times that of networknt and 6 times that of everit.
Benchmark Mode Cnt Score Error Units
JSONSchemaBenchmark.everit thrpt 5 3.182 ± 0.018 ops/ms
JSONSchemaBenchmark.fastjson2 thrpt 5 21.408 ± 0.147 ops/ms
JSONSchemaBenchmark.networknt thrpt 5 2.337 ± 0.007 ops/ms2. Direct Validation by Constructing a JSONSchema Object
/* Detailed source-code truncated for AI context efficiency. */3. Configuring schema on JSONField
Since version 2.0.4, you can configure a schema on the JSONField annotation to validate the input JSON data.
public static class Point1 {
@JSONField(schema = "{'minimum':-180,'maximum':180}")
public double longitude;
@JSONField(schema = "{'minimum':-90,'maximum':90}")
public double latitude;
}
@Test
public void test1() {
// parseObject validation passes
JSON.parseObject("{\"longitude\":120.1552,\"latitude\":30.2741}", Point1.class);
// JSONObject to JavaObject, validation passes
JSONObject.of("longitude", 120.1552, "latitude", 30.2741)
.to(Point1.class);
// parseObject validation fails, longitude exceeds the maximum value
assertThrows(JSONSchemaValidException.class, () ->
JSON.parseObject("{\"longitude\":220.1552,\"latitude\":30.2741}", Point1.class)
);
// Validate JSONObject fails, longitude exceeds the maximum value
assertThrows(JSONSchemaValidException.class, () ->
JSONObject.of("longitude", 220.1552, "latitude", 30.2741)
.to(Point1.class)
);
}4. Configuring schema on JSONType
Since version 2.0.4, you can configure a schema on the JSONType annotation to validate the input JSON data.
@JSONType(schema = "{'properties':{'longitude':{'type':'number','minimum':-180,'maximum':180},'latitude':{'type':'number','minimum':-90,'maximum':90}}}")
public static class Point2 {
@JSONField(schema = "{'minimum':-180,'maximum':180}")
public double longitude;
@JSONField(schema = "{'minimum':-90,'maximum':90}")
public double latitude;
}
@Test
public void test2() {
// parseObject validation passes
JSON.parseObject("{\"longitude\":120.1552,\"latitude\":30.2741}", Point2.class);
// JSONObject to JavaObject, validation passes
JSONObject.of("longitude", 120.1552, "latitude", 30.2741)
.to(Point2.class);
// parseObject validation fails, longitude exceeds the maximum value
assertThrows(JSONSchemaValidException.class, () ->
JSON.parseObject("{\"longitude\":220.1552,\"latitude\":30.2741}", Point2.class)
);
// Validate JSONObject fails, longitude exceeds the maximum value
assertThrows(JSONSchemaValidException.class, () ->
JSONObject.of("longitude", 220.1552, "latitude", 30.2741)
.to(Point2.class)
);
}5. Constructing JSONSchema from a Type
When interacting between the backend and frontend, it is often necessary to convert a Java type into a JSONSchema and return it to the client.
@Test
public void test() {
JSONSchema schema = JSONSchema.of(Bean.class);
String string = schema.toString();
assertEquals(
"{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"integer\"},\"name\":{\"type\":\"string\"}},\"required\":[\"id\"]}",
string
);
JSONSchema pased = JSONSchema.of(JSON.parseObject(string));
assertTrue(Differ.diff(schema, pased));
Bean bean = new Bean();
JSONSchema valueSchema = JSONSchema.ofValue(bean);
assertTrue(Differ.diff(schema, valueSchema));
}
public static class Bean {
public int id;
public String name;
}6. Constructing JSONSchema from a Value Object
@Test
public void fromValueMap() {
Map map = new HashMap();
map.put("id", 123);
assertEquals("{\"type\":\"object\",\"properties\":{\"id\":{\"type\":\"integer\"}}}", JSONSchema.ofValue(map).toString());
}Kotlin Kotlin Cn (`docs/Kotlin/kotlin_cn.md`)
1. 使用准备
如果项目使用Kotlin,可以使用fastjson-kotlin模块,使用方式上采用kotlin的特性。
1.1 添加依赖
Maven:
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-kotlin</artifactId>
<version>2.0.66</version>
</dependency>酌情添加标准库(kotlin-stdlib)、反射库(kotlin-reflect),
其中若使用数据类(data class)、通过构造函数传入参数则添加反射库。
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin-version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>${kotlin-version}</version>
</dependency>Kotlin Gradle:
dependencies {
implementation("com.alibaba.fastjson2:fastjson2-kotlin:2.0.66")
}dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version")
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")
}1.2 导包工作
每当调用fastjson-kotlin里的函数时,需要完成导包工作,否则会提示找不到相应函数。
例如:
import com.alibaba.fastjson2.to
import com.alibaba.fastjson2.into如果使用的函数很多时,可以使用通配符导入。
import com.alibaba.fastjson2.*2. 简单使用
这里,我们对函数名为to和into做了统一。
- 使用
to时利用::Class.java,适用于不含泛型的类。 - 使用
into时利用TypeReference,适用于含泛型的类。
首先实例定义一个公共类
class User(
var id: Int,
var name: String
)2.1 将`JSON`解析为`JSONObject`
val text = "..." // String
val data = text.parseObject()
val bytes = ... // ByteArray
val data = bytes.parseObject() // JSONObject2.2 将`JSON`解析为`JSONArray`
Kotlin:
val text = "..." // String
val data = text.parseArray() // JSONArray2.2 实例指定类的`TypeReference`
val refer = reference<User>()2.3 将`JSON`解析为实例对象
无泛型实例:
val text = "..." // String
val data = text.to<User>() // User含泛型实例:
val text = "..." // String
val data = text.into<List<User>>() // List<User>
val data = text.into<Map<String, User>>() // Map<String, User>2.4 将实例对象序列化为`JSON`
序列化为字符串:
val data = "..." // Any
val text = data.toJSONString() // String序列化为字节数组:
val data = "..." // Any
val bytes = data.toJSONByteArray() // ByteArray2.5 使用`JSONObject`、`JSONArray`
2.5.1 获取简单属性
val text = "..."
val data = JSON.parseObject(text) // JSONObject
val id = data.getIntValue("id") // Int
val name = data.getString("name") // String2.5.2 读取实例对象
无泛型实例:
val obj = ... // JSONObject
val array = ... // JSONArray
val user = array.to<User>(0)
val user = obj.to<User>("key")含泛型实例:
val obj = ... // JSONObject
val array = ... // JSONArray
val user = array.into<List<User>>(0)
val user = obj.into<List<User>>("key")2.5.3 转为实例对象
无泛型实例:
val obj = ... // JSONObject
val array = ... // JSONArray
val user = obj.to<User>() // User
val users = array.toList<User>() // List<User>含泛型实例:
val obj = ... // JSONObject
val array = ... // JSONArray
val user = obj.into<HashMap<String, User>>() // HashMap<String, User>
val users = array.into<ArrayList<User>>() // ArrayList<User>2.5 `URL`、`InputStream`转为实例对象
无泛型实例:
val url = ... // URL
val data = url.to<User>()val input = ... // InputStream
val data = input.to<User>()含泛型实例:
val url = ... // URL
val data = url.into<List<User>>()val input = ... // InputStream
val data = input.into<List<User>>()3. 进阶使用
3.1 使用`JSONPath`
3.1.1 使用`JSONPath`读取部分数据
val text = "..."
val path = "$.id".toPath() // JSONPath
val parser = JSONReader.of(text)
val result = path.extract(parser)Kotlin Kotlin En (`docs/Kotlin/kotlin_en.md`)
1. Prepare
If your project uses kotlin, you can use the Fastjson-Kotlin module, and use the characteristics of kotlin.
1.1 Download
Maven:
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-kotlin</artifactId>
<version>2.0.66</version>
</dependency>Add standard library(kotlin-stdlib) and reflection library(kotlin-reflect) as appropriate.
If the data class is used or the parameters are passed in through constructor, then add reflection library.
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib</artifactId>
<version>${kotlin-version}</version>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-reflect</artifactId>
<version>${kotlin-version}</version>
</dependency>Kotlin Gradle:
dependencies {
implementation("com.alibaba.fastjson2:fastjson2-kotlin:2.0.66")
}dependencies {
implementation("org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version")
implementation("org.jetbrains.kotlin:kotlin-reflect:$kotlin_version")
}1.2 Import functions
Whenever the function in the Fastjson-Kotlin, you need to complete the import functions work, otherwise it will be prompted that the corresponding function will not be found.
E.g:
import com.alibaba.fastjson2.to
import com.alibaba.fastjson2.intoIf you use a lot of functions, you can use batch import.
import com.alibaba.fastjson2.*2. Usage
We have unified function names to and into.
- Use
toto use::class.java, suitable for categories without generic Class. - Use
intoto use theTypeReference, which is suitable for genetic Class.
First define a User class
class User(
var id: Int,
var name: String
)2.1 Parse `JSON` into `JSONObject`
val text = "..." // String
val data = text.parseObject()
val bytes = ... // ByteArray
val data = bytes.parseObject() // JSONObject2.2 Parse `JSON` into `JSONArray`
Kotlin:
val text = "..." // String
val data = text.parseArray() // JSONArray2.2 Create the `Typereference` of specified Class
val refer = reference<User>()2.3 Parse `JSON` into an Object
No generic:
val text = "..." // String
val data = text.to<User>() // UserIncluding generic:
val text = "..." // String
val data = text.into<List<User>>() // List<User>
val data = text.into<Map<String, User>>() // Map<String, User>2.4 Serialization Object to `JSON`
Serialization as a string:
val data = "..." // Any
val text = data.toJSONString() // StringSerialization as a ByteArray:
val data = "..." // Any
val bytes = data.toJSONByteArray() // ByteArray2.5 Use `JSONObject`、`JSONArray`
2.5.1 Get simple property
val text = "..."
val data = JSON.parseObject(text) // JSONObject
val id = data.getIntValue("id") // Int
val name = data.getString("name") // String2.5.2 Get Bean Object
No generic:
val obj = ... // JSONObject
val array = ... // JSONArray
val user = array.to<User>(0)
val user = obj.to<User>("key")Including generic:
val obj = ... // JSONObject
val array = ... // JSONArray
val user = array.into<List<User>>(0)
val user = obj.into<List<User>>("key")2.5.3 Convert to Bean Object
No generic:
val obj = ... // JSONObject
val array = ... // JSONArray
val user = obj.to<User>() // User
val users = array.toList<User>() // List<User>Including generic:
val obj = ... // JSONObject
val array = ... // JSONArray
val user = obj.into<HashMap<String, User>>() // HashMap<String, User>
val users = array.into<ArrayList<User>>() // ArrayList<User>2.5 Convert `URL`、`InputStream` to Bean Object
No generic:
val url = ... // URL
val data = url.to<User>()val input = ... // InputStream
val data = input.to<User>()Including generic:
val url = ... // URL
val data = url.into<List<User>>()val input = ... // InputStream
val data = input.into<List<User>>()3. Advanced usage
3.1 Use `JSONPath`
3.1.1 Use `JSONPath` to read specified data
val text = "..."
val path = "$.id".toPath() // JSONPath
val parser = JSONReader.of(text)
val result = path.extract(parser)Spring Spring Support Cn (`docs/Spring/spring_support_cn.md`)
在 Spring 中集成 Fastjson2
0. 依赖配置
Fastjson2采用多module的结构设计,对SpringFramework等框架的支持现独立在extension包中。
Maven:
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-extension-spring5</artifactId>
<version>2.0.66</version>
</dependency>
or
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-extension-spring6</artifactId>
<version>2.0.66</version>
</dependency>Gradle:
dependencies {
implementation 'com.alibaba.fastjson2:fastjson2-extension-spring5:2.0.66'
}
or
dependencies {
implementation 'com.alibaba.fastjson2:fastjson2-extension-spring6:2.0.66'
}2.0.23版本之后为了兼容Spring 5.x / 6.x,将不同版本独立开不同的依赖包。
如使用2.0.23之前的版本,请参考:
Maven:
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-extension</artifactId>
<version>2.0.x</version>
</dependency>Gradle:
dependencies {
implementation 'com.alibaba.fastjson2:fastjson2-extension:2.0.x'
}1. 参数配置
Fastjson2对于序列化和反序列化的行为进行了重新设计,所以FastJsonConfig也会重新适配。
Package: com.alibaba.fastjson2.support.config.FastJsonConfig
Attributes:
| 参数 | 类型 | 描述 |
|---|---|---|
| charset | Charset | 指定的字符集,默认UTF-8 |
| dateFormat | String | 指定的日期格式,默认yyyy-MM-dd HH:mm:ss |
| writerFilters | Filter[] | 配置序列化过滤器 |
| writerFeatures | JSONWriter.Feature[] | 配置序列化的指定行为,更多配置请见:Features文档 |
| readerFilters | Filter[] | 配置反序列化过滤器 |
| readerFeatures | JSONReader.Feature[] | 配置反序列化的指定行为,更多配置请见:Features文档 |
| jsonb | boolean | 是否采用JSONB进行序列化和反序列化,默认false |
| symbolTable | JSONB.SymbolTable | JSONB序列化和反序列化的符号表,只有使用JSONB时生效 |
2. 在 Spring Web MVC 中集成 Fastjson2
在Fastjson2中,同样可以使用FastJsonHttpMessageConverter 和 FastJsonJsonView 为 Spring MVC 构建的 Web 应用提供更好的性能体验。
2. 配置FastJsonHttpMessageConverter
2.1 Spring MVC 7.0 及以上版本
从 Spring MVC 7.0 开始,configureMessageConverters(List<HttpMessageConverter<?>>) 方法已被弃用,改为使用新的 HttpMessageConverters.ServerBuilder 方式进行配置。
@Configuration
public class FastJsonWebMvcConfiguration extends WebMvcConfigurationSupport {
@Override
protected void configureMessageConverters(HttpMessageConverters.ServerBuilder builder) {
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
FastJsonConfig config = new FastJsonConfig();
config.setDateFormat("yyyy-MM-dd HH:mm:ss");
config.setCharset(StandardCharsets.UTF_8);
converter.setFastJsonConfig(config);
// 从2.0.60版本开始,FastJsonHttpMessageConverter默认charset已经是UTF-8,无需手动设置
// converter.setDefaultCharset(StandardCharsets.UTF_8);
// 使用 withJsonConverter 方法替换默认的 JSON 转换器
builder.withJsonConverter(converter);
}
}注意:Spring MVC 7.0 的 HttpMessageConverters.ServerBuilder 提供了不同的方法来配置不同类型的消息转换器:
withJsonConverter()- 用于配置 JSON 转换器withXmlConverter()- 用于配置 XML 转换器withStringConverter()- 用于配置字符串转换器addCustomConverter()- 用于添加自定义转换器(会添加到默认转换器之前)configureMessageConverters()- 用于配置所有已选择的消息转换器
2.2 Spring MVC 6.x 及以下版本
对于 Spring MVC 6.x 及以下版本,继续使用原有的配置方式:
@Configuration
public class FastJsonWebMvcConfiguration extends WebMvcConfigurationSupport {
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
FastJsonConfig config = new FastJsonConfig();
config.setDateFormat("yyyy-MM-dd HH:mm:ss");
config.setCharset(StandardCharsets.UTF_8);
converter.setFastJsonConfig(config);
// 从2.0.61版本开始,FastJsonHttpMessageConverter默认charset已经是UTF-8,无需手动设置
// converter.setDefaultCharset(StandardCharsets.UTF_8);
converters.add(0, converter);
}
}2.2 Spring Web MVC View
使用 FastJsonJsonView 来设置 Spring MVC 默认的视图模型解析器,以提高 @Controller @ResponseBody ModelAndView JSON序列化速度。
Package: com.alibaba.fastjson2.support.spring.webservlet.view.FastJsonJsonView
Before Spring 5 Example:
@Configuration
@EnableWebMvc
public class WebMvcConfigurer extends WebMvcConfigurerAdapter {
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
FastJsonJsonView fastJsonJsonView = new FastJsonJsonView();
//自定义配置...
//FastJsonConfig config = new FastJsonConfig();
//config.set...
//fastJsonJsonView.setFastJsonConfig(config);
registry.enableContentNegotiation(fastJsonJsonView);
}
}从Spring5.0版本开始,WebMvcConfigurerAdapter 已被弃用,您可以直接实现WebMvcConfigurer接口,而无需使用此适配器。
After Spring 5 Example:
@Configuration
@EnableWebMvc
public class CustomWebMvcConfigurer implements WebMvcConfigurer {
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
FastJsonJsonView fastJsonJsonView = new FastJsonJsonView();
//自定义配置...
//FastJsonConfig config = new FastJsonConfig();
//config.set...
//fastJsonJsonView.setFastJsonConfig(config);
registry.enableContentNegotiation(fastJsonJsonView);
}
}参考:Spring Framework 官方文档 Spring Web MVC 部分,查看更多 。
3. 在 Spring Webflux 中集成 Fastjson2
Fastjson2提供了针对Spring响应式编解码的支持,可以使用Fastjson2Decoder和Fastjson2Encoder来替换Spring默认的Decoder和Encoder。
Packages:
com.alibaba.fastjson2.support.spring.codec.Fastjson2Decodercom.alibaba.fastjson2.support.spring.codec.Fastjson2Encoder
Spring6 Packages:
com.alibaba.fastjson2.support.spring6.codec.Fastjson2Decodercom.alibaba.fastjson2.support.spring6.codec.Fastjson2Encoder
Example1:
@Configuration
public class CustomWebfluxConfigure implements WebFluxConfigurer {
@Override
public void configureHttpMessageCodecs(ServerCodecConfigurer configurer) {
//configurer.registerDefaults(false);
CodecConfigurer.CustomCodecs customCodecs = configurer.customCodecs();
//自定义配置
FastJsonConfig config = new FastJsonConfig();
config.setCharset(StandardCharsets.UTF_8);
config.setDateFormat("yyyy-MM-dd HH:mm:ss");
//设置支持的媒体类型
MimeType[] supportedMimeTypes = new MimeType[]{MediaType.APPLICATION_JSON};
//注册解码器
customCodecs.register(new Fastjson2Decoder(config,supportedMimeTypes));
//注册编码器
customCodecs.register(new Fastjson2Encoder(config,supportedMimeTypes));
}
}Example2:
@Bean
public CodecCustomizer codecCustomizer() {
return configurer -> {
//configurer.registerDefaults(false);
CodecConfigurer.CustomCodecs customCodecs = configurer.customCodecs();
//自定义配置
FastJsonConfig config = new FastJsonConfig();
config.setCharset(StandardCharsets.UTF_8);
config.setDateFormat("yyyy-MM-dd HH:mm:ss");
//设置支持的媒体类型
MimeType[] supportedMimeTypes = new MimeType[]{MediaType.APPLICATION_JSON};
//注册解码器
customCodecs.register(new Fastjson2Decoder(config, supportedMimeTypes));
//注册编码器
customCodecs.register(new Fastjson2Encoder(config, supportedMimeTypes));
};
}4. 在 Spring Web Socket 中集成 Fastjson2
在Fastjson2中,同样也对 Spring WebSocket 给予支持,可以使用 FastjsonSockJsMessageCodec 进行配置。
Package: com.alibaba.fastjson2.support.spring.websocket.sockjs.FastjsonSockJsMessageCodec
Example:
@Component
@EnableWebSocket
public class WebSocketConfig extends WebMvcConfigurerAdapter implements WebSocketConfigurer {
@Resource
WebSocketHandler handler;
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
//自定义配置...
//FastjsonSockJsMessageCodec messageCodec = new FastjsonSockJsMessageCodec();
//FastJsonConfig config = new FastJsonConfig();
//config.set...
//messageCodec.setFastJsonConfig(config);
registry.addHandler(handler, "/sockjs").withSockJS().setMessageCodec(new FastjsonSockJsMessageCodec());
}
}参考:Spring Framework 官方文档 Spring Web Socket 部分,查看更多 。
5. 在 Spring Data Redis 中集成 Fastjson2
在Fastjson2中,同样可以使用 GenericFastJsonRedisSerializer 或 FastJsonRedisSerializer 为 Spring Data Redis 提供更好的性能体验。
5.1 Generic Redis Serializer
使用 GenericFastJsonRedisSerializer 作为 RedisTemplate 的 RedisSerializer 来提升JSON序列化和反序列化速度。
Package: com.alibaba.fastjson2.support.spring.data.redis.GenericFastJsonRedisSerializer
Example:
@Configuration
public class RedisConfiguration {
@Bean
public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate redisTemplate = new RedisTemplate();
redisTemplate.setConnectionFactory(redisConnectionFactory);
GenericFastJsonRedisSerializer fastJsonRedisSerializer = new GenericFastJsonRedisSerializer();
redisTemplate.setDefaultSerializer(fastJsonRedisSerializer);//设置默认的Serialize,包含 keySerializer & valueSerializer
//redisTemplate.setKeySerializer(fastJsonRedisSerializer);//单独设置keySerializer
//redisTemplate.setValueSerializer(fastJsonRedisSerializer);//单独设置valueSerializer
return redisTemplate;
}
}5.2 Customized Redis Serializer
通常使用 GenericFastJsonRedisSerializer 即可满足大部分场景,如果你想定义特定类型专用的 RedisTemplate 可以使用 FastJsonRedisSerializer
来代替 GenericFastJsonRedisSerializer ,配置是类似的。
Package: com.alibaba.fastjson2.support.spring.data.redis.FastJsonRedisSerializer
Example:
@Configuration
public class RedisConfiguration {
@Bean
public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate redisTemplate = new RedisTemplate();
redisTemplate.setConnectionFactory(redisConnectionFactory);
FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(User.class);
redisTemplate.setDefaultSerializer(fastJsonRedisSerializer);
return redisTemplate;
}
}5.3 JSONB Redis Serializer
如果你准备使用 JSONB 作为对象序列/反序列化的方式并对序列化速度有较高的要求的话,可以对jsonb参数进行配置,该参数是 fastjson 2.0.6 版本中新增的支持,配置也很简单。
Example:
@Configuration
public class RedisConfiguration {
@Bean
public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate redisTemplate = new RedisTemplate();
redisTemplate.setConnectionFactory(redisConnectionFactory);
// GenericFastJsonRedisSerializer use jsonb
// GenericFastJsonRedisSerializer fastJsonRedisSerializer = new GenericFastJsonRedisSerializer(true);
// FastJsonRedisSerializer use jsonb
FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(User.class);
// FastJsonConfig fastJsonConfig = new FastJsonConfig();
// fastJsonConfig.setJSONB(true);
// fastJsonRedisSerializer.setFastJsonConfig(fastJsonConfig);
redisTemplate.setDefaultSerializer(fastJsonRedisSerializer);
return redisTemplate;
}
}参考:Spring Data Redis 官方文档,查看更多 。
6. 在 Spring Messaging 中集成 Fastjson2
在Fastjson2中,同样可以使用 MappingFastJsonMessageConverter 为 Spring Messaging 提供更好的性能体验。
6.1 JSON Message Converter
使用 MappingFastJsonMessageConverter 作为 Spring Cloud Stream 或 Spring Messaging 来提升Message的序列化和反序列化速度。
Package: com.alibaba.fastjson2.support.spring.messaging.converter.MappingFastJsonMessageConverter
Example:
@Configuration
public class StreamConfiguration {
@Bean
@StreamMessageConverter
public MappingFastJsonMessageConverter messageConverter() {
return new MappingFastJsonMessageConverter();
}
}6.2 JSONB Message Converter
如果你准备使用 JSONB 作为对象序列/反序列化的方式并对序列化速度有较高的要求的话,可以对 FastJsonConfig 的 jsonb 参数进行配置,该参数是 fastjson 2.0.6 版本中新增的支持,配置也很简单。
注意:JSONB仅支持将Message的payload序列化为byte[]
Example:
@Configuration
public class StreamConfiguration {
@Bean
@StreamMessageConverter
public MappingFastJsonMessageConverter messageConverter() {
MappingFastJsonMessageConverter messageConverter = new MappingFastJsonMessageConverter();
FastJsonConfig fastJsonConfig = new FastJsonConfig();
fastJsonConfig.setJSONB(true); // use jsonb
messageConverter.setFastJsonConfig(fastJsonConfig);
return messageConverter;
}
}参考:Spring Messaging 官方文档,查看更多 。
Spring Spring Support En (`docs/Spring/spring_support_en.md`)
Integrate Fastjson2 in SpringFramework
0. Download
Fastjson2 adopts a multi-module structure design, and the support for frameworks such as SpringFramework is now
independent in the extension dependency.
Maven:
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-extension-spring5</artifactId>
<version>2.0.66</version>
</dependency>
or
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-extension-spring6</artifactId>
<version>2.0.66</version>
</dependency>Gradle:
dependencies {
implementation 'com.alibaba.fastjson2:fastjson2-extension-spring5:2.0.66'
}
or
dependencies {
implementation 'com.alibaba.fastjson2:fastjson2-extension-spring6:2.0.66'
}After version 2.0.23, in order to be compatible with Spring 5.x / 6.x, different versions are independently opened with different dependency packages.
If using a version earlier than 2.0.23, please refer to:
Maven:
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2-extension</artifactId>
<version>2.0.x</version>
</dependency>Gradle:
dependencies {
implementation 'com.alibaba.fastjson2:fastjson2-extension:2.0.x'
}1. Configuration
Fastjson2 has redesigned the behavior of serialization and deserialization, so FastJsonConfig will also be re-adapted.
Package: com.alibaba.fastjson2.support.config.FastJsonConfig
Attributes:
| param | Type | Desc |
|---|---|---|
| charset | Charset | The specified character set, default UTF-8 |
| dateFormat | String | The specified date format, default yyyy-MM-dd HH:mm:ss |
| writerFilters | Filter[] | Configure serialization filters |
| writerFeatures | JSONWriter.Feature[] | Configure the specified behavior of serialization. For more configuration, see Features |
| readerFilters | Filter[] | Configure deserialization filters |
| readerFeatures | JSONReader.Feature[] | Configure the specified behavior of deserialization. For more configuration, see Features |
| jsonb | boolean | Use JSONB for serialization and deserialization, the default is false |
| symbolTable | JSONB.SymbolTable | JSONB serialization and deserialization symbol table, only valid when using JSONB |
2. Integrate Fastjson2 in Spring Web MVC
In Fastjson2, FastJsonHttpMessageConverter and FastJsonJsonView can also be used to provide a better performance
experience for Web applications built with Spring MVC.
2. Configure FastJsonHttpMessageConverter
2.1 Spring MVC 7.0 and Above
Starting from Spring MVC 7.0, the configureMessageConverters(List<HttpMessageConverter<?>>) method has been deprecated in favor of the new HttpMessageConverters.ServerBuilder approach.
@Configuration
public class FastJsonWebMvcConfiguration extends WebMvcConfigurationSupport {
@Override
protected void configureMessageConverters(HttpMessageConverters.ServerBuilder builder) {
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
FastJsonConfig config = new FastJsonConfig();
config.setDateFormat("yyyy-MM-dd HH:mm:ss");
config.setCharset(StandardCharsets.UTF_8);
converter.setFastJsonConfig(config);
// From version 2.0.60, FastJsonHttpMessageConverter default charset is already UTF-8, no need to set manually
// converter.setDefaultCharset(StandardCharsets.UTF_8);
// Use withJsonConverter to replace the default JSON converter
builder.withJsonConverter(converter);
}
}Note: Spring MVC 7.0's HttpMessageConverters.ServerBuilder provides different methods to configure different types of message converters:
withJsonConverter()- Configure JSON converterwithXmlConverter()- Configure XML converterwithStringConverter()- Configure String converteraddCustomConverter()- Add custom converter (will be added before default converters)configureMessageConverters()- Configure all selected message converters
2.2 Spring MVC 6.x and Below
For Spring MVC 6.x and below, continue using the original configuration method:
@Configuration
public class FastJsonWebMvcConfiguration extends WebMvcConfigurationSupport {
@Override
public void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
FastJsonConfig config = new FastJsonConfig();
config.setDateFormat("yyyy-MM-dd HH:mm:ss");
config.setCharset(StandardCharsets.UTF_8);
converter.setFastJsonConfig(config);
// From version 2.0.61, FastJsonHttpMessageConverter default charset is already UTF-8, no need to set manually
// converter.setDefaultCharset(StandardCharsets.UTF_8);
converters.add(0, converter);
}
}2.2 Spring Web MVC View
Use FastJsonJsonView to set Spring MVC's default view model resolver to improve the speed
of @Controller @ResponseBody ModelAndView JSON serialization.
Package: com.alibaba.fastjson2.support.spring.webservlet.view.FastJsonJsonView
Before Spring 5 Example:
@Configuration
@EnableWebMvc
public class WebMvcConfigurer extends WebMvcConfigurerAdapter {
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
FastJsonJsonView fastJsonJsonView = new FastJsonJsonView();
//custom configuration...
//FastJsonConfig config = new FastJsonConfig();
//config.set...
//fastJsonJsonView.setFastJsonConfig(config);
registry.enableContentNegotiation(fastJsonJsonView);
}
}Starting from Spring 5.0, WebMvcConfigurerAdapter has been deprecated, you can directly implement the WebMvcConfigurer interface without using this adapter.
After Spring 5 Example:
@Configuration
@EnableWebMvc
public class CustomWebMvcConfigurer implements WebMvcConfigurer {
@Override
public void configureViewResolvers(ViewResolverRegistry registry) {
FastJsonJsonView fastJsonJsonView = new FastJsonJsonView();
//custom configuration...
//FastJsonConfig config = new FastJsonConfig();
//config.set...
//fastJsonJsonView.setFastJsonConfig(config);
registry.enableContentNegotiation(fastJsonJsonView);
}
}Reference: Spring Framework official documentation Spring Web MVC section, For more configuration.
3. Integrate Fastjson2 in Spring Webflux
Fastjson2 provides support for reactive codec in Spring, to replace Spring's default Decoder and Encoder with Fastjson2Decoder and Fastjson2Encoder.
Packages:
com.alibaba.fastjson2.support.spring.codec.Fastjson2Decodercom.alibaba.fastjson2.support.spring.codec.Fastjson2Encoder
Spring6 Packages:
com.alibaba.fastjson2.support.spring6.codec.Fastjson2Decodercom.alibaba.fastjson2.support.spring6.codec.Fastjson2Encoder
Example1:
@Configuration
public class CustomWebfluxConfigure implements WebFluxConfigurer {
@Override
public void configureHttpMessageCodecs(ServerCodecConfigurer configurer) {
//configurer.registerDefaults(false);
CodecConfigurer.CustomCodecs customCodecs = configurer.customCodecs();
//自定义配置
FastJsonConfig config = new FastJsonConfig();
config.setCharset(StandardCharsets.UTF_8);
config.setDateFormat("yyyy-MM-dd HH:mm:ss");
//设置支持的媒体类型
MimeType[] supportedMimeTypes = new MimeType[]{MediaType.APPLICATION_JSON};
//注册解码器
customCodecs.register(new Fastjson2Decoder(config,supportedMimeTypes));
//注册编码器
customCodecs.register(new Fastjson2Encoder(config,supportedMimeTypes));
}
}Example2:
@Bean
public CodecCustomizer codecCustomizer() {
return configurer -> {
//configurer.registerDefaults(false);
CodecConfigurer.CustomCodecs customCodecs = configurer.customCodecs();
//自定义配置
FastJsonConfig config = new FastJsonConfig();
config.setCharset(StandardCharsets.UTF_8);
config.setDateFormat("yyyy-MM-dd HH:mm:ss");
//设置支持的媒体类型
MimeType[] supportedMimeTypes = new MimeType[]{MediaType.APPLICATION_JSON};
//注册解码器
customCodecs.register(new Fastjson2Decoder(config, supportedMimeTypes));
//注册编码器
customCodecs.register(new Fastjson2Encoder(config, supportedMimeTypes));
};
}4. Integrate Fastjson2 in Spring Web Socket
In Fastjson2, Spring WebSocket is also supported, which can be configured using FastjsonSockJsMessageCodec.
Package: com.alibaba.fastjson2.support.spring.websocket.sockjs.FastjsonSockJsMessageCodec
Example:
@Component
@EnableWebSocket
public class WebSocketConfig extends WebMvcConfigurerAdapter implements WebSocketConfigurer {
@Resource
WebSocketHandler handler;
public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) {
//custom configuration...
//FastjsonSockJsMessageCodec messageCodec = new FastjsonSockJsMessageCodec();
//FastJsonConfig config = new FastJsonConfig();
//config.set...
//messageCodec.setFastJsonConfig(config);
registry.addHandler(handler, "/sockjs").withSockJS().setMessageCodec(new FastjsonSockJsMessageCodec());
}
}Reference: Spring Framework official documentation Spring Web Socket section, For more configuration.
5. Integrate Fastjson2 in Spring Data Redis
In Fastjson2, you can also use GenericFastJsonRedisSerializer or FastJsonRedisSerializer to provide a better
performance experience for Spring Data Redis.
5.1 Generic Redis Serializer
Use GenericFastJsonRedisSerializer as the RedisSerializer of RedisTemplate to improve JSON serialization and
deserialization speed.
Package: com.alibaba.fastjson2.support.spring.data.redis.GenericFastJsonRedisSerializer
Example:
@Configuration
public class RedisConfiguration {
@Bean
public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate redisTemplate = new RedisTemplate();
redisTemplate.setConnectionFactory(redisConnectionFactory);
GenericFastJsonRedisSerializer fastJsonRedisSerializer = new GenericFastJsonRedisSerializer();
redisTemplate.setDefaultSerializer(fastJsonRedisSerializer);//Set the default Serialize, including keySerializer & valueSerializer
//redisTemplate.setKeySerializer(fastJsonRedisSerializer);//Only set keySerializer
//redisTemplate.setValueSerializer(fastJsonRedisSerializer);//Only set valueSerializer
return redisTemplate;
}
}5.2 Customized Redis Serializer
Usually, GenericFastJsonRedisSerializer can be used for most scenarios. If you want to define a specific type
of RedisTemplate, you can use FastJsonRedisSerializer instead of GenericFastJsonRedisSerializer , the
configuration is similar.
Package: com.alibaba.fastjson2.support.spring.data.redis.FastJsonRedisSerializer
Example:
@Configuration
public class RedisConfiguration {
@Bean
public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate redisTemplate = new RedisTemplate();
redisTemplate.setConnectionFactory(redisConnectionFactory);
FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(User.class);
redisTemplate.setDefaultSerializer(fastJsonRedisSerializer);
return redisTemplate;
}
}5.3 JSONB Redis Serializer
If you plan to use JSONB as an object serialization/deserialization method and have higher serialization speed
requirements, you can configure the jsonb parameter, which is a new support in fastjson 2.0.6, and the configuration
is also very simple.
Example:
@Configuration
public class RedisConfiguration {
@Bean
public RedisTemplate redisTemplate(RedisConnectionFactory redisConnectionFactory) {
RedisTemplate redisTemplate = new RedisTemplate();
redisTemplate.setConnectionFactory(redisConnectionFactory);
// GenericFastJsonRedisSerializer use jsonb
// GenericFastJsonRedisSerializer fastJsonRedisSerializer = new GenericFastJsonRedisSerializer(true);
// FastJsonRedisSerializer use jsonb
FastJsonRedisSerializer fastJsonRedisSerializer = new FastJsonRedisSerializer(User.class);
// FastJsonConfig fastJsonConfig = new FastJsonConfig();
// fastJsonConfig.setJSONB(true);
// fastJsonRedisSerializer.setFastJsonConfig(fastJsonConfig);
redisTemplate.setDefaultSerializer(fastJsonRedisSerializer);
return redisTemplate;
}
}Reference: Spring Data Redis official documentation, For more configuration.
6. Integrate Fastjson2 in Spring Messaging
In Fastjson2, you can use MappingFastJsonMessageConverter to provide a better performance experience for Spring
Messaging.
6.1 JSON Message Converter
Use MappingFastJsonMessageConverter as Spring Cloud Stream or Spring Messaging to speed up message serialization and
deserialization.
Package: com.alibaba.fastjson2.support.spring.messaging.converter.MappingFastJsonMessageConverter
Example:
@Configuration
public class StreamConfiguration {
@Bean
@StreamMessageConverter
public MappingFastJsonMessageConverter messageConverter() {
return new MappingFastJsonMessageConverter();
}
}6.2 JSONB Message Converter
If you plan to use JSONB as the object serialization/deserialization method and have high requirements on serialization
speed, you can configure the jsonb parameter of FastJsonConfig, which is a new support in fastjson 2.0.6 version ,
the configuration is also very simple.
Note: JSONB only supports serializing the payload of Message to byte[]
Example:
@Configuration
public class StreamConfiguration {
@Bean
@StreamMessageConverter
public MappingFastJsonMessageConverter messageConverter() {
MappingFastJsonMessageConverter messageConverter = new MappingFastJsonMessageConverter();
FastJsonConfig fastJsonConfig = new FastJsonConfig();
fastJsonConfig.setJSONB(true); // use jsonb
messageConverter.setFastJsonConfig(fastJsonConfig);
return messageConverter;
}
}Reference: Spring Messaging official documentation, For more configuration.
Benchmark Benchmark 2.0.10 (`docs/benchmark/benchmark_2.0.10.md`)
EishayParseBinary
| fastjson2JSONB | fastjson2UTF8Bytes | hessian | javaSerialize | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 1662.519 | 1068.155 (64.25%) | 294.621 (17.72%) | 46.934 (2.82%) |
| ecs.c7.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 1608.327 | 1103.765 (68.63%) | 296.119 (18.41%) | 48.219 (3%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 2232.906 | 1198.964 (53.7%) | 245.589 (11%) | 48.624 (2.18%) |
| ecs.c7.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 2156.968 | 1192.374 (55.28%) | 249.473 (11.57%) | 49.163 (2.28%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 2117.7 | 1230.879 (58.12%) | 257.134 (12.14%) | 52.371 (2.47%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 1295.39 | 897.15 (69.26%) | 263.668 (20.35%) | 45.149 (3.49%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 2076.715 | 1118.745 (53.87%) | 252.291 (12.15%) | 46.861 (2.26%) |
| ecs.c7a.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 2088.989 | 1112.484 (53.25%) | 254.349 (12.18%) | 46.304 (2.22%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 2196.505 | 1154.667 (52.57%) | 252.689 (11.5%) | 53.14 (2.42%) |
| ecs.c7a.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 1303.461 | 919.496 (70.54%) | 273.322 (20.97%) | 44.628 (3.42%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 1259.145 | 739.592 (58.74%) | 191.592 (15.22%) | 37.251 (2.96%) |
| ecs.c6r.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 1266.241 | 741.578 (58.57%) | 188.709 (14.9%) | 37.492 (2.96%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1446.584 | 761.311 (52.63%) | 181.532 (12.55%) | 37.329 (2.58%) |
| ecs.c6r.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 1448.242 | 766.322 (52.91%) | 181.316 (12.52%) | 33.496 (2.31%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1315.523 | 781.266 (59.39%) | 187.004 (14.22%) | 36.889 (2.8%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 1229.35 | 783.486 (63.73%) | 199.997 (16.27%) | 41.822 (3.4%) |
| ecs.g8m.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 1149.392 | 772.304 (67.19%) | 196.319 (17.08%) | 41.273 (3.59%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1838.38 | 997.282 (54.25%) | 205.768 (11.19%) | 39.459 (2.15%) |
| ecs.g8m.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 1845.763 | 1012.428 (54.85%) | 182.695 (9.9%) | 39.196 (2.12%) |
| ecs.g8m.xlarge-jdk-17.0.3.1_aarch64 | 1672.166 | 1017.511 (60.85%) | 204.05 (12.2%) | 37.239 (2.23%) |
EishayParseString
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 1330.465 | 1052.245 (79.09%) | 539.298 (40.53%) |
| ecs.c7.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 1268.333 | 1027.487 (81.01%) | 554.306 (43.7%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 1083.776 | 928.745 (85.7%) | 504.486 (46.55%) |
| ecs.c7.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 1101.361 | 938.282 (85.19%) | 487.466 (44.26%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 1153.576 | 1254.472 (108.75%) | 494.308 (42.85%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 1248.78 | 999.915 (80.07%) | 509.819 (40.83%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 1255.488 | 925.928 (73.75%) | 496.43 (39.54%) |
| ecs.c7a.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 1266.894 | 896.124 (70.73%) | 487.243 (38.46%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 1225.869 | 1321.998 (107.84%) | 525.009 (42.83%) |
| ecs.c7a.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 1265.732 | 1028.402 (81.25%) | 531.05 (41.96%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 886.091 | 728.983 (82.27%) | 374.762 (42.29%) |
| ecs.c6r.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 878.859 | 727.034 (82.72%) | 380.587 (43.3%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 803.554 | 737.579 (91.79%) | 378.636 (47.12%) |
| ecs.c6r.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 805.432 | 718.395 (89.19%) | 375.392 (46.61%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 813.333 | 1016.732 (125.01%) | 376.125 (46.24%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 898.391 | 729.564 (81.21%) | 361.718 (40.26%) |
| ecs.g8m.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 911.296 | 729.367 (80.04%) | 359.238 (39.42%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1059.243 | 807.538 (76.24%) | 412.46 (38.94%) |
| ecs.g8m.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 1051.04 | 813.991 (77.45%) | 406.579 (38.68%) |
| ecs.g8m.xlarge-jdk-17.0.3.1_aarch64 | 801.957 | 1016.377 (126.74%) | 378.544 (47.2%) |
EishayParseStringPretty
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 993.493 | 263.938 (26.57%) | 492.713 (49.59%) |
| ecs.c7.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 970.574 | 266.479 (27.46%) | 488.244 (50.3%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 830.543 | 236.262 (28.45%) | 479.819 (57.77%) |
| ecs.c7.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 839.77 | 242.631 (28.89%) | 443.493 (52.81%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 906.43 | 301.759 (33.29%) | 482.707 (53.25%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 948.652 | 271.879 (28.66%) | 488.876 (51.53%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 807.452 | 250.321 (31%) | 455.017 (56.35%) |
| ecs.c7a.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 876.438 | 250.965 (28.63%) | 470.533 (53.69%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 916.15 | 304.231 (33.21%) | 470.382 (51.34%) |
| ecs.c7a.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 943.569 | 281.096 (29.79%) | 487.608 (51.68%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 700.991 | 209.916 (29.95%) | 349.593 (49.87%) |
| ecs.c6r.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 697.75 | 209.392 (30.01%) | 351.059 (50.31%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 629.493 | 213.512 (33.92%) | 351.648 (55.86%) |
| ecs.c6r.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 632.541 | 213.144 (33.7%) | 349.5 (55.25%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 629.213 | 240.931 (38.29%) | 349.078 (55.48%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 706.889 | 213.623 (30.22%) | 329.4 (46.6%) |
| ecs.g8m.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 727.173 | 212.729 (29.25%) | 332.007 (45.66%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 720.909 | 217.186 (30.13%) | 380.032 (52.72%) |
| ecs.g8m.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 726.619 | 223.32 (30.73%) | 362.706 (49.92%) |
| ecs.g8m.xlarge-jdk-17.0.3.1_aarch64 | 706.404 | 267.123 (37.81%) | 383.156 (54.24%) |
EishayParseTreeString
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 884.202 | 505.807 (57.2%) | 514.607 (58.2%) |
| ecs.c7.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 886.178 | 492.095 (55.53%) | 513.204 (57.91%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 668.231 | 406.932 (60.9%) | 442.83 (66.27%) |
| ecs.c7.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 632.424 | 406.427 (64.26%) | 435.481 (68.86%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 814.91 | 583.6 (71.62%) | 503.005 (61.73%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 804.767 | 469.922 (58.39%) | 544.027 (67.6%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 738.988 | 410.463 (55.54%) | 503.278 (68.1%) |
| ecs.c7a.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 695.187 | 403.258 (58.01%) | 496.18 (71.37%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 824.736 | 552.48 (66.99%) | 538.679 (65.32%) |
| ecs.c7a.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 812.683 | 474.493 (58.39%) | 538.347 (66.24%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 527.307 | 301.027 (57.09%) | 359.851 (68.24%) |
| ecs.c6r.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 528.116 | 303.429 (57.45%) | 358.328 (67.85%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 464.011 | 322.167 (69.43%) | 350.13 (75.46%) |
| ecs.c6r.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 451.639 | 316.342 (70.04%) | 355.475 (78.71%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 515.964 | 360.932 (69.95%) | 382.892 (74.21%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 502.385 | 292.152 (58.15%) | 310.522 (61.81%) |
| ecs.g8m.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 451.266 | 298.738 (66.2%) | 314.887 (69.78%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 531.137 | 364.984 (68.72%) | 378.267 (71.22%) |
| ecs.g8m.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 513.514 | 360.291 (70.16%) | 379.154 (73.84%) |
| ecs.g8m.xlarge-jdk-17.0.3.1_aarch64 | 549.215 | 405.991 (73.92%) | 433.562 (78.94%) |
EishayParseTreeStringPretty
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 728.712 | 445.895 (61.19%) | 486.229 (66.72%) |
| ecs.c7.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 701.812 | 442.536 (63.06%) | 467.816 (66.66%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 542.655 | 353.202 (65.09%) | 396.616 (73.09%) |
| ecs.c7.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 540.629 | 355.131 (65.69%) | 411.856 (76.18%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 669.672 | 478.699 (71.48%) | 452.588 (67.58%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 688.778 | 415.206 (60.28%) | 480.278 (69.73%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 618.788 | 355.102 (57.39%) | 459.78 (74.3%) |
| ecs.c7a.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 612.543 | 347.602 (56.75%) | 424.358 (69.28%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 687.269 | 435.903 (63.43%) | 509.11 (74.08%) |
| ecs.c7a.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 682.417 | 426.479 (62.5%) | 502.93 (73.7%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 452.328 | 268.158 (59.28%) | 332.058 (73.41%) |
| ecs.c6r.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 454.156 | 267.86 (58.98%) | 330.509 (72.77%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 407.294 | 274.322 (67.35%) | 321.445 (78.92%) |
| ecs.c6r.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 397.878 | 267.272 (67.17%) | 325.605 (81.84%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 442.606 | 310.646 (70.19%) | 354.225 (80.03%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 418.374 | 273.817 (65.45%) | 301.418 (72.05%) |
| ecs.g8m.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 397.505 | 272.775 (68.62%) | 297.158 (74.76%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 450.737 | 286.024 (63.46%) | 359.291 (79.71%) |
| ecs.g8m.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 447.926 | 284.157 (63.44%) | 355.973 (79.47%) |
| ecs.g8m.xlarge-jdk-17.0.3.1_aarch64 | 411.277 | 373.162 (90.73%) | 388.116 (94.37%) |
EishayParseTreeUTF8Bytes
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 666.782 | 437.243 (65.58%) | 618.889 (92.82%) |
| ecs.c7.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 652.349 | 457.998 (70.21%) | 593.488 (90.98%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 630.875 | 366.212 (58.05%) | 505.251 (80.09%) |
| ecs.c7.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 639.517 | 364.722 (57.03%) | 488.571 (76.4%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 839.938 | 486.746 (57.95%) | 554.496 (66.02%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 551.935 | 427.317 (77.42%) | 619.338 (112.21%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 587.225 | 363.691 (61.93%) | 532.067 (90.61%) |
| ecs.c7a.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 685.734 | 359.531 (52.43%) | 537.863 (78.44%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 743.535 | 462.667 (62.23%) | 567.373 (76.31%) |
| ecs.c7a.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 560.017 | 429.193 (76.64%) | 577.59 (103.14%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 464.174 | 249.351 (53.72%) | 433.715 (93.44%) |
| ecs.c6r.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 465.321 | 246.684 (53.01%) | 435.721 (93.64%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 498.887 | 283.606 (56.85%) | 419.456 (84.08%) |
| ecs.c6r.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 498.745 | 285.87 (57.32%) | 421.664 (84.55%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 470.215 | 323.753 (68.85%) | 452.523 (96.24%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 398.413 | 248.939 (62.48%) | 360.871 (90.58%) |
| ecs.g8m.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 395.934 | 249.571 (63.03%) | 355.552 (89.8%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 613.987 | 330.696 (53.86%) | 443.384 (72.21%) |
| ecs.g8m.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 628.532 | 303.167 (48.23%) | 442.201 (70.35%) |
| ecs.g8m.xlarge-jdk-17.0.3.1_aarch64 | 590.016 | 352.067 (59.67%) | 494.386 (83.79%) |
EishayParseTreeUTF8BytesPretty
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 565.316 | 378.525 (66.96%) | 523.692 (92.64%) |
| ecs.c7.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 556.527 | 396.588 (71.26%) | 532.999 (95.77%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 565.773 | 315.848 (55.83%) | 466.738 (82.5%) |
| ecs.c7.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 542.904 | 320.391 (59.01%) | 471.093 (86.77%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 646.611 | 408.827 (63.23%) | 501.745 (77.6%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 504.762 | 364.954 (72.3%) | 519.72 (102.96%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 585.827 | 317.301 (54.16%) | 494.312 (84.38%) |
| ecs.c7a.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 605.425 | 310.895 (51.35%) | 483.779 (79.91%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 621.383 | 396.746 (63.85%) | 532.66 (85.72%) |
| ecs.c7a.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 518.266 | 370.181 (71.43%) | 550.101 (106.14%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 414.154 | 222.112 (53.63%) | 400.566 (96.72%) |
| ecs.c6r.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 416.388 | 219.373 (52.68%) | 400.155 (96.1%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 389.966 | 242.185 (62.1%) | 386.453 (99.1%) |
| ecs.c6r.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 431.693 | 238.828 (55.32%) | 384.144 (88.99%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 410.013 | 272.439 (66.45%) | 408.881 (99.72%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 360.731 | 226.937 (62.91%) | 338.262 (93.77%) |
| ecs.g8m.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 364.33 | 237.157 (65.09%) | 328.406 (90.14%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 463.958 | 252.096 (54.34%) | 419.43 (90.4%) |
| ecs.g8m.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 468.227 | 215.64 (46.05%) | 408.765 (87.3%) |
| ecs.g8m.xlarge-jdk-17.0.3.1_aarch64 | 508.726 | 311.12 (61.16%) | 445.622 (87.6%) |
EishayParseUTF8Bytes
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 1054.54 | 795.252 (75.41%) | 632.874 (60.01%) |
| ecs.c7.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 1063.765 | 808.83 (76.03%) | 632.485 (59.46%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 1134.334 | 749.883 (66.11%) | 543.711 (47.93%) |
| ecs.c7.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 1156.761 | 724.865 (62.66%) | 559.768 (48.39%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 1168.44 | 945.948 (80.96%) | 564.128 (48.28%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 885.485 | 798.175 (90.14%) | 634.178 (71.62%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 1071.866 | 701.996 (65.49%) | 584.131 (54.5%) |
| ecs.c7a.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 1136.496 | 698.184 (61.43%) | 494.19 (43.48%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 1118.599 | 929.372 (83.08%) | 616.024 (55.07%) |
| ecs.c7a.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 912.29 | 825.891 (90.53%) | 621.963 (68.18%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 736.224 | 570.667 (77.51%) | 458.517 (62.28%) |
| ecs.c6r.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 736.938 | 573.946 (77.88%) | 457.212 (62.04%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 758.368 | 582.85 (76.86%) | 443.043 (58.42%) |
| ecs.c6r.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 760.607 | 588.879 (77.42%) | 436.257 (57.36%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 774.254 | 756.405 (97.69%) | 442.324 (57.13%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 774.569 | 656.149 (84.71%) | 394.389 (50.92%) |
| ecs.g8m.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 763.387 | 656.725 (86.03%) | 391.664 (51.31%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 983.395 | 665.54 (67.68%) | 467.372 (47.53%) |
| ecs.g8m.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 922.826 | 671.856 (72.8%) | 492.797 (53.4%) |
| ecs.g8m.xlarge-jdk-17.0.3.1_aarch64 | 985.945 | 561.237 (56.92%) | 459.987 (46.65%) |
EishayParseUTF8BytesPretty
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 780.68 | 239.856 (30.72%) | 561.16 (71.88%) |
| ecs.c7.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 850.798 | 248.802 (29.24%) | 554.252 (65.14%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 848.488 | 222.873 (26.27%) | 519.831 (61.27%) |
| ecs.c7.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 839.096 | 224.652 (26.77%) | 513.033 (61.14%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 898.354 | 269.718 (30.02%) | 514.051 (57.22%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 700.44 | 255.108 (36.42%) | 560.242 (79.98%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 815.146 | 230.026 (28.22%) | 506.154 (62.09%) |
| ecs.c7a.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 817.219 | 229.557 (28.09%) | 499.091 (61.07%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 834.118 | 273.836 (32.83%) | 566.191 (67.88%) |
| ecs.c7a.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 752.102 | 253.088 (33.65%) | 538.827 (71.64%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 608.072 | 191.658 (31.52%) | 424.902 (69.88%) |
| ecs.c6r.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 610.174 | 191.631 (31.41%) | 416.174 (68.21%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 597.413 | 196.281 (32.86%) | 407.177 (68.16%) |
| ecs.c6r.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 598.328 | 193.022 (32.26%) | 397.424 (66.42%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 606.488 | 220.139 (36.3%) | 395.848 (65.27%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 650.351 | 199.403 (30.66%) | 366.552 (56.36%) |
| ecs.g8m.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 636.182 | 199.239 (31.32%) | 363.332 (57.11%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 738.723 | 166.992 (22.61%) | 434.729 (58.85%) |
| ecs.g8m.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 737.354 | 160.468 (21.76%) | 436.026 (59.13%) |
| ecs.g8m.xlarge-jdk-17.0.3.1_aarch64 | 756.144 | 238.842 (31.59%) | 386.943 (51.17%) |
EishayWriteBinary
| fastjson2JSONB | fastjson2UTF8Bytes | hessian | javaSerialize | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 2204.73 | 1567.588 (71.1%) | 339.036 (15.38%) | 233.26 (10.58%) |
| ecs.c7.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 2218.276 | 1657.917 (74.74%) | 342.832 (15.45%) | 234.024 (10.55%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 1790.216 | 1601.189 (89.44%) | 327.999 (18.32%) | 208.74 (11.66%) |
| ecs.c7.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 1821.773 | 1587.164 (87.12%) | 329.376 (18.08%) | 199.489 (10.95%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 2394.527 | 1847.581 (77.16%) | 313.237 (13.08%) | 217.566 (9.09%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 1976.789 | 1449.003 (73.3%) | 401.999 (20.34%) | 230.439 (11.66%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 2064.608 | 1722.414 (83.43%) | 398.114 (19.28%) | 235.669 (11.41%) |
| ecs.c7a.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 2072.525 | 1740.579 (83.98%) | 398.086 (19.21%) | 236.322 (11.4%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 2043.693 | 1741.294 (85.2%) | 404.138 (19.77%) | 258.442 (12.65%) |
| ecs.c7a.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 1988.417 | 1660.568 (83.51%) | 424.743 (21.36%) | 234.501 (11.79%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 1358.211 | 1112.988 (81.95%) | 290.754 (21.41%) | 178.874 (13.17%) |
| ecs.c6r.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 1369.87 | 1116.709 (81.52%) | 294.791 (21.52%) | 183.017 (13.36%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1512.423 | 1171.179 (77.44%) | 312.033 (20.63%) | 197.12 (13.03%) |
| ecs.c6r.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 1536.555 | 1165.207 (75.83%) | 320.387 (20.85%) | 189.621 (12.34%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1492.434 | 1173.374 (78.62%) | 308.133 (20.65%) | 182.57 (12.23%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 1632.504 | 1331.857 (81.58%) | 349.661 (21.42%) | 203.287 (12.45%) |
| ecs.g8m.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 1605.403 | 1326.657 (82.64%) | 352.833 (21.98%) | 207.318 (12.91%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1785.141 | 1400.051 (78.43%) | 324.735 (18.19%) | 219.345 (12.29%) |
| ecs.g8m.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 1828.642 | 1401.848 (76.66%) | 346.687 (18.96%) | 219.75 (12.02%) |
| ecs.g8m.xlarge-jdk-17.0.3.1_aarch64 | 1838.101 | 1340.471 (72.93%) | 353.44 (19.23%) | 207.792 (11.3%) |
EishayWriteString
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 1648.856 | 608.91 (36.93%) | 1014.767 (61.54%) |
| ecs.c7.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 1619.627 | 606.315 (37.44%) | 1007.513 (62.21%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 1552.358 | 582.688 (37.54%) | 912.945 (58.81%) |
| ecs.c7.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 1567.336 | 588.448 (37.54%) | 930.531 (59.37%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 1869.477 | 607.486 (32.49%) | 1034.663 (55.35%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 1654.445 | 634.006 (38.32%) | 974.538 (58.9%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 1694.193 | 616.51 (36.39%) | 937.633 (55.34%) |
| ecs.c7a.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 1647.232 | 640.661 (38.89%) | 938.309 (56.96%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 1813.681 | 671.19 (37.01%) | 1002.787 (55.29%) |
| ecs.c7a.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 1698.899 | 633.241 (37.27%) | 948.419 (55.83%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 1051.455 | 470.782 (44.77%) | 575.745 (54.76%) |
| ecs.c6r.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 1049.427 | 461.525 (43.98%) | 587.58 (55.99%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1116.747 | 426.228 (38.17%) | 625.569 (56.02%) |
| ecs.c6r.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 1117.908 | 434.763 (38.89%) | 631.987 (56.53%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1123.387 | 484.995 (43.17%) | 621.077 (55.29%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 1227.901 | 469.014 (38.2%) | 656.713 (53.48%) |
| ecs.g8m.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 1249.711 | 454.395 (36.36%) | 662.743 (53.03%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1332.77 | 542.833 (40.73%) | 674.677 (50.62%) |
| ecs.g8m.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 1339.633 | 430.502 (32.14%) | 683.856 (51.05%) |
| ecs.g8m.xlarge-jdk-17.0.3.1_aarch64 | 1368.147 | 387.271 (28.31%) | 648.755 (47.42%) |
EishayWriteUTF8Bytes
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 1563.425 | 577.73 (36.95%) | 920.223 (58.86%) |
| ecs.c7.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 1653.0 | 577.922 (34.96%) | 933.162 (56.45%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 1613.901 | 527.765 (32.7%) | 828.189 (51.32%) |
| ecs.c7.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 1607.841 | 530.983 (33.02%) | 827.989 (51.5%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 1910.387 | 560.816 (29.36%) | 966.689 (50.6%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 1534.605 | 581.306 (37.88%) | 813.978 (53.04%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 1672.726 | 558.311 (33.38%) | 839.934 (50.21%) |
| ecs.c7a.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64 | 1722.781 | 555.951 (32.27%) | 836.485 (48.55%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 1849.535 | 579.97 (31.36%) | 899.426 (48.63%) |
| ecs.c7a.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64 | 1648.003 | 574.148 (34.84%) | 786.185 (47.71%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 1113.309 | 421.211 (37.83%) | 577.765 (51.9%) |
| ecs.c6r.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 1117.753 | 426.244 (38.13%) | 580.387 (51.92%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1163.434 | 383.164 (32.93%) | 559.367 (48.08%) |
| ecs.c6r.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 1174.883 | 390.054 (33.2%) | 561.1 (47.76%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1159.227 | 383.186 (33.06%) | 607.941 (52.44%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 1324.723 | 462.229 (34.89%) | 668.319 (50.45%) |
| ecs.g8m.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64 | 1333.112 | 465.33 (34.91%) | 669.571 (50.23%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1393.749 | 418.782 (30.05%) | 459.995 (33%) |
| ecs.g8m.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64 | 1408.242 | 334.409 (23.75%) | 641.197 (45.53%) |
| ecs.g8m.xlarge-jdk-17.0.3.1_aarch64 | 1408.569 | 439.425 (31.2%) | 645.993 (45.86%) |
Benchmark Benchmark 2.0.10 Raw (`docs/benchmark/benchmark_2.0.10_raw.md`)
ecs.c7.xlarge-oracle-jdk1.8.0_333_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7.xlarge-zulu17.34.19-ca-jdk17.0.3-linux_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7a.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7a.xlarge-zulu17.34.19-ca-jdk17.0.3-linux_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7a.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.c6r.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.c6r.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.c6r.xlarge-zulu17.34.19-ca-jdk17.0.3-linux_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.g8m.xlarge-zulu8.62.0.19-ca-jdk8.0.332-linux_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.g8m.xlarge-zulu11.56.19-ca-jdk11.0.15-linux_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.g8m.xlarge-jdk-17.0.3.1_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.g8m.xlarge-zulu17.34.19-ca-jdk17.0.3-linux_aarch64
/* Detailed source-code truncated for AI context efficiency. */Benchmark Benchmark 2.0.11 (`docs/benchmark/benchmark_2.0.11.md`)
EishayParseBinary
| fastjson2JSONB | fastjson2UTF8Bytes | hessian | javaSerialize | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 1653.429 | 1064.852 (64.4%) | 296.075 (17.91%) | 46.304 (2.8%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 2158.358 | 1178.136 (54.58%) | 250.26 (11.59%) | 48.974 (2.27%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 2289.931 | 1186.102 (51.8%) | 259.273 (11.32%) | 52.155 (2.28%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 1283.367 | 894.826 (69.72%) | 271.677 (21.17%) | 43.842 (3.42%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 2018.912 | 1024.287 (50.73%) | 249.239 (12.35%) | 46.501 (2.3%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 2205.599 | 1108.391 (50.25%) | 252.089 (11.43%) | 53.899 (2.44%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 1249.166 | 737.424 (59.03%) | 192.867 (15.44%) | 37.459 (3%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1422.66 | 758.159 (53.29%) | 180.314 (12.67%) | 35.677 (2.51%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1308.243 | 765.378 (58.5%) | 188.977 (14.45%) | 38.777 (2.96%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 1268.634 | 811.239 (63.95%) | 204.273 (16.1%) | 42.148 (3.32%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1806.889 | 985.783 (54.56%) | 207.365 (11.48%) | 40.837 (2.26%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1624.198 | 964.707 (59.4%) | 208.791 (12.86%) | 40.712 (2.51%) |
EishayParseString
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 1229.76 | 1032.002 (83.92%) | 537.086 (43.67%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 1084.264 | 920.176 (84.87%) | 478.882 (44.17%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 1190.061 | 1237.583 (103.99%) | 509.479 (42.81%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 1079.079 | 1053.13 (97.6%) | 524.081 (48.57%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 1089.023 | 935.063 (85.86%) | 505.022 (46.37%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 1079.245 | 1311.413 (121.51%) | 534.158 (49.49%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 800.011 | 719.323 (89.91%) | 380.487 (47.56%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 781.207 | 739.1 (94.61%) | 368.89 (47.22%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 796.691 | 1013.746 (127.24%) | 378.512 (47.51%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 866.221 | 762.108 (87.98%) | 372.786 (43.04%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 996.206 | 812.669 (81.58%) | 415.83 (41.74%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 986.339 | 1135.27 (115.1%) | 423.949 (42.98%) |
EishayParseStringPretty
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 924.465 | 271.988 (29.42%) | 493.505 (53.38%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 844.38 | 238.483 (28.24%) | 476.466 (56.43%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 924.891 | 296.387 (32.05%) | 454.865 (49.18%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 869.583 | 281.521 (32.37%) | 488.286 (56.15%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 736.85 | 256.88 (34.86%) | 438.951 (59.57%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 824.279 | 306.065 (37.13%) | 490.708 (59.53%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 645.953 | 208.1 (32.22%) | 345.632 (53.51%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 615.745 | 214.168 (34.78%) | 346.284 (56.24%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 625.214 | 241.908 (38.69%) | 351.847 (56.28%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 713.548 | 217.765 (30.52%) | 339.58 (47.59%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 730.943 | 221.501 (30.3%) | 382.546 (52.34%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 745.319 | 264.298 (35.46%) | 385.093 (51.67%) |
EishayParseTreeString
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 940.068 | 520.689 (55.39%) | 544.252 (57.89%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 742.855 | 390.367 (52.55%) | 456.475 (61.45%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 1026.086 | 538.156 (52.45%) | 496.96 (48.43%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 852.335 | 472.658 (55.45%) | 532.155 (62.43%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 784.804 | 424.508 (54.09%) | 484.077 (61.68%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 932.383 | 536.621 (57.55%) | 521.452 (55.93%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 562.632 | 305.48 (54.29%) | 351.903 (62.55%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 518.655 | 322.972 (62.27%) | 353.653 (68.19%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 590.854 | 357.914 (60.58%) | 382.306 (64.7%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 578.699 | 315.505 (54.52%) | 333.253 (57.59%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 622.239 | 351.351 (56.47%) | 378.825 (60.88%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 744.176 | 421.855 (56.69%) | 421.189 (56.6%) |
EishayParseTreeStringPretty
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 751.857 | 456.069 (60.66%) | 474.533 (63.11%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 662.555 | 344.586 (52.01%) | 418.977 (63.24%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 804.762 | 477.307 (59.31%) | 449.729 (55.88%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 707.513 | 423.598 (59.87%) | 477.149 (67.44%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 605.985 | 358.492 (59.16%) | 430.489 (71.04%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 694.376 | 454.288 (65.42%) | 504.901 (72.71%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 484.719 | 266.932 (55.07%) | 326.265 (67.31%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 443.277 | 274.911 (62.02%) | 328.248 (74.05%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 489.889 | 302.911 (61.83%) | 353.183 (72.09%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 491.525 | 288.438 (58.68%) | 308.619 (62.79%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 527.758 | 286.784 (54.34%) | 355.794 (67.42%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 610.878 | 371.707 (60.85%) | 382.634 (62.64%) |
EishayParseTreeUTF8Bytes
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 878.063 | 444.307 (50.6%) | 604.576 (68.85%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 693.831 | 375.454 (54.11%) | 524.835 (75.64%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 1039.879 | 491.333 (47.25%) | 570.869 (54.9%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 724.409 | 425.516 (58.74%) | 611.344 (84.39%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 701.542 | 359.164 (51.2%) | 546.392 (77.88%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 969.424 | 462.715 (47.73%) | 609.116 (62.83%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 536.367 | 249.322 (46.48%) | 435.246 (81.15%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 458.988 | 283.658 (61.8%) | 419.631 (91.43%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 587.175 | 319.199 (54.36%) | 450.736 (76.76%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 522.389 | 255.568 (48.92%) | 379.229 (72.6%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 540.736 | 334.569 (61.87%) | 442.68 (81.87%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 764.182 | 325.005 (42.53%) | 493.639 (64.6%) |
EishayParseTreeUTF8BytesPretty
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 742.573 | 396.169 (53.35%) | 528.268 (71.14%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 565.508 | 311.963 (55.17%) | 473.617 (83.75%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 870.722 | 414.169 (47.57%) | 512.404 (58.85%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 640.911 | 365.268 (56.99%) | 509.636 (79.52%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 615.454 | 307.071 (49.89%) | 495.122 (80.45%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 682.724 | 406.35 (59.52%) | 557.424 (81.65%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 475.312 | 221.822 (46.67%) | 406.613 (85.55%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 401.657 | 242.737 (60.43%) | 384.611 (95.76%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 499.815 | 271.072 (54.23%) | 409.21 (81.87%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 470.784 | 234.63 (49.84%) | 360.044 (76.48%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 475.107 | 259.69 (54.66%) | 409.671 (86.23%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 618.583 | 314.073 (50.77%) | 444.471 (71.85%) |
EishayParseUTF8Bytes
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 1051.114 | 807.736 (76.85%) | 633.364 (60.26%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 1069.704 | 729.829 (68.23%) | 563.902 (52.72%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 1181.305 | 959.515 (81.23%) | 567.976 (48.08%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 885.434 | 795.931 (89.89%) | 617.025 (69.69%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 1086.723 | 703.671 (64.75%) | 577.449 (53.14%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 1093.175 | 942.769 (86.24%) | 629.499 (57.58%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 730.896 | 573.061 (78.41%) | 462.948 (63.34%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 751.32 | 581.111 (77.35%) | 434.922 (57.89%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 773.593 | 758.432 (98.04%) | 435.238 (56.26%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 789.153 | 685.705 (86.89%) | 427.618 (54.19%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 963.31 | 662.034 (68.72%) | 478.684 (49.69%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 877.131 | 658.124 (75.03%) | 441.58 (50.34%) |
EishayParseUTF8BytesPretty
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 780.819 | 248.376 (31.81%) | 554.36 (71%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 822.492 | 223.248 (27.14%) | 483.196 (58.75%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 909.074 | 268.617 (29.55%) | 509.581 (56.05%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 708.969 | 250.274 (35.3%) | 547.598 (77.24%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 758.635 | 226.687 (29.88%) | 531.269 (70.03%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 837.449 | 261.94 (31.28%) | 524.298 (62.61%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 607.265 | 190.348 (31.35%) | 413.44 (68.08%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 594.68 | 193.972 (32.62%) | 405.96 (68.27%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 606.65 | 216.927 (35.76%) | 402.788 (66.4%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 663.908 | 205.985 (31.03%) | 391.486 (58.97%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 730.548 | 189.934 (26%) | 436.026 (59.68%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 731.274 | 245.953 (33.63%) | 394.64 (53.97%) |
EishayWriteBinary
| fastjson2JSONB | fastjson2UTF8Bytes | hessian | javaSerialize | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 2188.069 | 1555.14 (71.07%) | 347.604 (15.89%) | 224.955 (10.28%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 1785.598 | 1568.733 (87.85%) | 334.082 (18.71%) | 203.571 (11.4%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 2348.795 | 1843.268 (78.48%) | 321.465 (13.69%) | 231.795 (9.87%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 1996.561 | 1514.665 (75.86%) | 413.412 (20.71%) | 234.234 (11.73%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 2003.397 | 1581.271 (78.93%) | 402.565 (20.09%) | 239.1 (11.93%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 2075.635 | 1712.945 (82.53%) | 409.364 (19.72%) | 258.898 (12.47%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 1355.006 | 1144.396 (84.46%) | 292.71 (21.6%) | 179.278 (13.23%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1507.309 | 1206.237 (80.03%) | 320.748 (21.28%) | 189.272 (12.56%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1489.544 | 1201.131 (80.64%) | 312.906 (21.01%) | 190.096 (12.76%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 1644.519 | 1367.341 (83.15%) | 333.57 (20.28%) | 207.834 (12.64%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1791.692 | 1399.304 (78.1%) | 336.145 (18.76%) | 219.033 (12.22%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1834.978 | 1413.351 (77.02%) | 343.673 (18.73%) | 204.131 (11.12%) |
EishayWriteString
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 1668.56 | 605.201 (36.27%) | 987.455 (59.18%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 1467.147 | 593.275 (40.44%) | 923.318 (62.93%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 1811.661 | 608.777 (33.6%) | 1025.491 (56.61%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 1504.976 | 637.493 (42.36%) | 952.046 (63.26%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 1542.499 | 620.194 (40.21%) | 922.975 (59.84%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 1726.045 | 658.103 (38.13%) | 949.383 (55%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 1074.739 | 471.736 (43.89%) | 584.382 (54.37%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1140.738 | 444.487 (38.96%) | 620.403 (54.39%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1151.088 | 442.427 (38.44%) | 611.171 (53.1%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 1267.626 | 477.102 (37.64%) | 651.529 (51.4%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1337.509 | 461.515 (34.51%) | 673.314 (50.34%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1364.217 | 466.142 (34.17%) | 663.001 (48.6%) |
EishayWriteUTF8Bytes
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 1549.608 | 562.484 (36.3%) | 906.145 (58.48%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 1548.346 | 527.833 (34.09%) | 843.441 (54.47%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 1883.364 | 546.698 (29.03%) | 939.609 (49.89%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 1500.179 | 572.65 (38.17%) | 842.196 (56.14%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 1649.071 | 563.771 (34.19%) | 831.416 (50.42%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 1650.147 | 590.163 (35.76%) | 891.54 (54.03%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 1149.608 | 428.644 (37.29%) | 576.807 (50.17%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1205.428 | 416.627 (34.56%) | 560.422 (46.49%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1192.178 | 419.126 (35.16%) | 612.583 (51.38%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 1363.883 | 440.125 (32.27%) | 661.013 (48.47%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1405.911 | 367.176 (26.12%) | 625.346 (44.48%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1403.622 | 444.734 (31.68%) | 690.402 (49.19%) |
Benchmark Benchmark 2.0.11 Raw (`docs/benchmark/benchmark_2.0.11_raw.md`)
ecs.c7.xlarge-oracle-jdk1.8.0_333_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64
/* Detailed source-code truncated for AI context efficiency. */Benchmark Benchmark 2.0.12 (`docs/benchmark/benchmark_2.0.12.md`)
1. 测试环境
1.1 服务器环境
测试的服务器基于阿里云最新代ECS,包括x64架构的Intel和AMD处理器,ARM架构的AltraMax和阿里云平头哥的倚天处理器。
ecs.c7.xlarge
这个是阿里云当前代标准型ECS,处理器型号 Intel Xeon(Ice Lake) Platinum 8369B,4核,8G内存ecs.c7a.xlarge
这个是阿里云当前代标准型ECS,处理器型号 AMD EPYC™ Milan 7T83,4核,8G内存ecs.c6r.xlarge
这个是阿里云上售卖ARM处理器ECS,处理器型号 Ampere Altra / AltraMax,4核,8G内存ecs.g8m.xlarge
这个是阿里云上售卖ARM处理器,处理器型号 Yitian 710,4核,16G内存。这个是阿里云平头哥的倚天710处理器,需要联系客服才能购买。
1.2 JDK版本
基于Oracle最新版本的Linux x64/aarch64的JDK版本,下载地址 https://www.oracle.com/java/technologies/
- oracle-jdk1.8.0_341
- oracle-jdk-11.0.16
- oracle-jdk-17.0.4
- oracle-jdk-18.0.2
1.3 测试代码以及运行方式
运行方式测试代码方式
git clone https://github.com/alibaba/fastjson2
cd fastjson2
git checkout 2.0.12
mvn clean install -Dmaven.test.skip
~/Install/jdk-1.8.0_341/bin/java -cp ~/git/fastjson2/benchmark/target/fastjson2-benchmarks.jar com.alibaba.fastjson2.benchmark.eishay.Eishay
~/Install/jdk-11.0.16/bin/java -cp ~/git/fastjson2/benchmark/target/fastjson2-benchmarks.jar com.alibaba.fastjson2.benchmark.eishay.Eishay
~/Install/jdk-17.0.4/bin/java -cp ~/git/fastjson2/benchmark/target/fastjson2-benchmarks.jar com.alibaba.fastjson2.benchmark.eishay.Eishay
~/Install/jdk-18.0.2/bin/java -cp ~/git/fastjson2/benchmark/target/fastjson2-benchmarks.jar com.alibaba.fastjson2.benchmark.eishay.EishayEishayParseString
这个是最常用的场景,将JSON格式字符串反序列化为Java对象,这个场景在fastjson中的代码如下:
String str = "...";
Bean bean = JSON.parseJSONObject(str, Bean.class);这个场景是fastjson1最强的场景;
在ecs.c7.xlarge-oracle-jdk1.8.0_341_x64环境中,只相当于fastjson2的76.16%;jackson则只相当于fastjson2的41.62%;gson是fastjson2的34.44%。
性能排序如下:
// ecs.c7.xlarge-oracle-jdk1.8.0_341_x64
fastjson2 > fastjson1 > jackson > gson
100% 76.16% 41.62% 34.44%下面是不同CPU不同JDK下的性能比较表格,第一列是阿里云机器规格和JDK的版本信息,第二列到第五列是JMH的Throughput数据,越大越好。
第三列到第五列中的百分比是Throughput相比fastjson2的比,比如第三列的百分比是fastjson1/fastjson2的百分数表示。
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 1280.79 | 975.417 (76.16%) | 533.05 (41.62%) | 441.098 (34.44%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 1156.746 | 923.166 (79.81%) | 484.755 (41.91%) | 432.261 (37.37%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 1271.058 | 1245.138 (97.96%) | 488.057 (38.4%) | 458.173 (36.05%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1285.745 | 1162.7 (90.43%) | 497.201 (38.67%) | 416.679 (32.41%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 1232.166 | 997.019 (80.92%) | 516.422 (41.91%) | 454.289 (36.87%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 1074.775 | 928.247 (86.37%) | 496.175 (46.17%) | 468.162 (43.56%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 1237.042 | 1323.952 (107.03%) | 529.334 (42.79%) | 536.419 (43.36%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 1226.619 | 1192.121 (97.19%) | 481.629 (39.26%) | 467.084 (38.08%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 843.629 | 719.256 (85.26%) | 383.128 (45.41%) | 313.66 (37.18%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 828.013 | 734.647 (88.72%) | 377.617 (45.61%) | 318.57 (38.47%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 853.772 | 1020.291 (119.5%) | 379.463 (44.45%) | 318.711 (37.33%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 849.58 | 995.946 (117.23%) | 362.179 (42.63%) | 303.018 (35.67%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 917.802 | 737.61 (80.37%) | 370.102 (40.32%) | 353.573 (38.52%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 1026.274 | 802.58 (78.2%) | 408.008 (39.76%) | 376.903 (36.73%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 1030.558 | 1026.0 (99.56%) | 392.415 (38.08%) | 244.263 (23.7%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 1089.054 | 999.211 (91.75%) | 396.401 (36.4%) | 268.559 (24.66%) |
EishayParseStringPretty
这个场景是将格式化过的JSON格式字符串反序列化为Java对象,这个场景fastjson1的parse算法不擅长的。这个场景fastjson2表现仍然非常好。
这个场景在ecs.c7.xlarge-oracle-jdk1.8.0_341_x64环境下,fastjson1的性能是fastjson2的27.29%,jackson的性能是fastjson2的50.56%,gson是fastjson2的43.01%.
这个场景在fastjson中的代码如下:
// 这里输入的是格式化过后的json字符串
String str = "{\n" +
"\t\"id\":123\n" +
"}";
Bean bean = JSON.parseJSONObject(str, Bean.class);性能排序分别如下:
// ecs.c7.xlarge-oracle-jdk1.8.0_341_x64
fastjson2 > jackson > gson > fastjson1
100% 50.56% 43.01% 27.29%下面是不同CPU不同JDK下的性能比较表格,第一列是阿里云机器规格和JDK的版本信息,第二列到第五列是JMH的Throughput数据,越大越好。
第三列到第五列中的百分比是Throughput相比fastjson2的比,比如第三列的百分比是fastjson1/fastjson2的百分数表示。
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 963.195 | 262.851 (27.29%) | 486.976 (50.56%) | 414.293 (43.01%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 872.125 | 241.835 (27.73%) | 477.263 (54.72%) | 404.389 (46.37%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 955.065 | 299.972 (31.41%) | 480.246 (50.28%) | 420.784 (44.06%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 955.217 | 289.455 (30.3%) | 462.899 (48.46%) | 391.052 (40.94%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 915.908 | 280.182 (30.59%) | 459.843 (50.21%) | 426.466 (46.56%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 828.309 | 250.989 (30.3%) | 461.404 (55.7%) | 407.729 (49.22%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 849.51 | 301.561 (35.5%) | 462.203 (54.41%) | 485.299 (57.13%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 831.064 | 296.826 (35.72%) | 468.978 (56.43%) | 432.39 (52.03%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 669.478 | 208.992 (31.22%) | 348.335 (52.03%) | 277.598 (41.46%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 644.651 | 212.15 (32.91%) | 341.676 (53%) | 296.356 (45.97%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 655.857 | 241.67 (36.85%) | 350.738 (53.48%) | 293.984 (44.82%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 652.962 | 229.365 (35.13%) | 332.02 (50.85%) | 278.116 (42.59%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 714.792 | 214.501 (30.01%) | 349.959 (48.96%) | 323.449 (45.25%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 752.608 | 231.712 (30.79%) | 383.271 (50.93%) | 347.639 (46.19%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 784.183 | 259.68 (33.11%) | 387.016 (49.35%) | 317.655 (40.51%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 782.402 | 247.16 (31.59%) | 359.573 (45.96%) | 323.368 (41.33%) |
EishayParseTreeString
这个场景是将JSON格式字符串反序列化为JSONObject,这也是一个最常见的场景之一,这个场景在fastjson中的代码如下:
String str = "...";
JSONObject jsonObject = JSON.parseJSONObject(str);fastjson2在这个场景也表现了远超fastjson1/jackson/gson的性能。
在不同的环境中,fastjson1和jackson都只能相当于fastjson1性能的40%~60%,gson则更差一些。
性能排序如下:
// ecs.c7.xlarge-oracle-jdk1.8.0_341_x64
fastjson2 > fastjson1 > jackson > gson
100% 55.39% 54.29% 36.53%下面是不同CPU不同JDK下的性能比较表格,第一列是阿里云机器规格和JDK的版本信息,第二列到第五列是JMH的Throughput数据,越大越好。
第三列到第五列中的百分比是Throughput相比fastjson2的比,比如第三列的百分比是fastjson1/fastjson2的百分数表示。
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 933.434 | 517.022 (55.39%) | 506.806 (54.29%) | 340.962 (36.53%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 774.516 | 394.826 (50.98%) | 440.933 (56.93%) | 322.93 (41.69%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 1024.532 | 583.808 (56.98%) | 505.817 (49.37%) | 320.666 (31.3%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1067.726 | 529.394 (49.58%) | 471.898 (44.2%) | 324.342 (30.38%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 880.183 | 474.715 (53.93%) | 519.486 (59.02%) | 362.992 (41.24%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 797.78 | 403.234 (50.54%) | 484.84 (60.77%) | 374.36 (46.93%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 979.102 | 536.398 (54.78%) | 564.281 (57.63%) | 397.783 (40.63%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 1010.951 | 521.952 (51.63%) | 543.735 (53.78%) | 396.25 (39.2%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 576.868 | 305.566 (52.97%) | 356.642 (61.82%) | 256.349 (44.44%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 533.525 | 319.366 (59.86%) | 355.745 (66.68%) | 260.384 (48.8%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 611.576 | 357.592 (58.47%) | 385.607 (63.05%) | 257.244 (42.06%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 612.693 | 340.3 (55.54%) | 375.034 (61.21%) | 255.753 (41.74%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 551.643 | 308.559 (55.93%) | 320.324 (58.07%) | 260.041 (47.14%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 655.95 | 361.855 (55.17%) | 382.319 (58.28%) | 306.29 (46.69%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 787.272 | 412.435 (52.39%) | 426.889 (54.22%) | 245.45 (31.18%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 793.481 | 368.496 (46.44%) | 414.609 (52.25%) | 279.315 (35.2%) |
EishayParseTreeStringPretty
这个场景在fastjson中的代码如下:
// 这里输入的是格式化过后的json字符串
String str = "{\n" +
"\t\"id\":123\n" +
"}";
JSONObject jsonObject = JSON.parseJSONObject(str);fastjson2在这个场景也表现了远超fastjson1/jackson/gson的性能。
性能排序如下:
// ecs.c7.xlarge-oracle-jdk1.8.0_341_x64
fastjson2 > jackson > fastjson1 > gson
100% 63.68% 60.43% 43.28%下面是不同CPU不同JDK下的性能比较表格,第一列是阿里云机器规格和JDK的版本信息,第二列到第五列是JMH的Throughput数据,越大越好。
第三列到第五列中的百分比是Throughput相比fastjson2的比,比如第三列的百分比是fastjson1/fastjson2的百分数表示。
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 744.185 | 449.72 (60.43%) | 473.933 (63.68%) | 322.106 (43.28%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 613.163 | 344.72 (56.22%) | 417.245 (68.05%) | 309.322 (50.45%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 814.548 | 483.549 (59.36%) | 454.505 (55.8%) | 301.853 (37.06%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 835.176 | 479.556 (57.42%) | 459.29 (54.99%) | 301.324 (36.08%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 705.798 | 423.443 (59.99%) | 475.629 (67.39%) | 333.679 (47.28%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 611.819 | 356.926 (58.34%) | 441.875 (72.22%) | 344.588 (56.32%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 752.479 | 472.299 (62.77%) | 483.349 (64.23%) | 371.936 (49.43%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 781.802 | 465.518 (59.54%) | 504.176 (64.49%) | 345.81 (44.23%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 493.539 | 267.924 (54.29%) | 330.741 (67.01%) | 239.599 (48.55%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 457.78 | 274.412 (59.94%) | 326.581 (71.34%) | 246.084 (53.76%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 501.855 | 311.258 (62.02%) | 350.552 (69.85%) | 245.072 (48.83%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 500.836 | 292.854 (58.47%) | 337.513 (67.39%) | 240.535 (48.03%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 465.583 | 286.793 (61.6%) | 308.676 (66.3%) | 248.297 (53.33%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 542.036 | 283.319 (52.27%) | 355.39 (65.57%) | 288.205 (53.17%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 618.605 | 367.727 (59.44%) | 375.298 (60.67%) | 265.321 (42.89%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 606.432 | 337.089 (55.59%) | 355.232 (58.58%) | 250.433 (41.3%) |
EishayParseUTF8Bytes
这个是将UTF8格式的byte数组反序列化为Java对象,这个场景在缓存和RPC场景中常用。
这个场景在fastjson中的代码如下:
byte[] utf8Bytes = ...;
Bean bean = JSON.parseJSONObject(utf8Bytes, Bean.class);这个场景fastjson2同样表现出了卓越的性能;在JDK8下,fastjson1和jackson的性能分别之后fastjson2的50.49%和63.22%;
gson不直接支持输入utf8Bytes,需要先构造字符串,性能只有fastjson2的35%。
性能排序如下:
// ecs.c7.xlarge-oracle-jdk1.8.0_341_x64
fastjson2 > fastjson1 > jackson > gson
100% 71.36% 57.27% 29.08%下面是不同CPU不同JDK下的性能比较表格,第一列是阿里云机器规格和JDK的版本信息,第二列到第五列是JMH的Throughput数据,越大越好。
第三列到第五列中的百分比是Throughput相比fastjson2的比,比如第三列的百分比是fastjson1/fastjson2的百分数表示。
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 1083.498 | 773.228 (71.36%) | 620.496 (57.27%) | 315.12 (29.08%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 1110.444 | 755.773 (68.06%) | 548.41 (49.39%) | 306.689 (27.62%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 1207.359 | 951.476 (78.81%) | 567.635 (47.01%) | 316.653 (26.23%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1121.7 | 893.757 (79.68%) | 563.522 (50.24%) | 319.072 (28.45%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 916.079 | 807.567 (88.15%) | 605.357 (66.08%) | 328.311 (35.84%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 1083.919 | 721.734 (66.59%) | 587.903 (54.24%) | 357.015 (32.94%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 1135.129 | 906.3 (79.84%) | 619.861 (54.61%) | 385.474 (33.96%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 1091.062 | 902.03 (82.67%) | 584.882 (53.61%) | 383.314 (35.13%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 723.162 | 563.093 (77.87%) | 455.927 (63.05%) | 239.648 (33.14%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 743.157 | 592.675 (79.75%) | 442.215 (59.5%) | 254.261 (34.21%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 766.054 | 758.582 (99.02%) | 429.762 (56.1%) | 253.173 (33.05%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 715.554 | 742.419 (103.75%) | 417.566 (58.36%) | 252.146 (35.24%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 806.11 | 658.904 (81.74%) | 423.583 (52.55%) | 240.131 (29.79%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 924.035 | 683.072 (73.92%) | 478.147 (51.75%) | 284.194 (30.76%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 975.486 | 767.593 (78.69%) | 440.031 (45.11%) | 276.31 (28.33%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 922.588 | 789.418 (85.57%) | 453.087 (49.11%) | 283.509 (30.73%) |
EishayParseUTF8BytesPretty
这个是将格式化过后的UTF8格式的byte数组反序列化为Java对象,这个场景在缓存和RPC场景中常用。
这个场景在fastjson中的代码如下:
// 这里输入的是格式化过后的json字符串
String str = "{\n" +
"\t\"id\":123\n" +
"}";
byte[] utf8Bytes = str.getBytes(StandardCharsets.UTF_8);
Bean bean = JSON.parseJSONObject(utf8Bytes, Bean.class);这个场景fastjson2同样表现出了卓越的性能;在JDK8下,fastjson1和jackson的性能分别之后fastjson2的53.72%和70.22%,
gson不直接支持输入utf8Bytes,需要先构造字符串,性能只有fastjson2的41.25%。
性能排序如下:
// ecs.c7.xlarge-oracle-jdk1.8.0_341_x64
fastjson2 > jackson > gson > fastjson1
100% 67.78% 37.4% 31.93%下面是不同CPU不同JDK下的性能比较表格,第一列是阿里云机器规格和JDK的版本信息,第二列到第五列是JMH的Throughput数据,越大越好。
第三列到第五列中的百分比是Throughput相比fastjson2的比,比如第三列的百分比是fastjson1/fastjson2的百分数表示。
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 786.524 | 251.142 (31.93%) | 533.112 (67.78%) | 294.143 (37.4%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 834.493 | 225.711 (27.05%) | 498.434 (59.73%) | 303.7 (36.39%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 905.466 | 271.031 (29.93%) | 508.311 (56.14%) | 303.584 (33.53%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 872.907 | 258.943 (29.66%) | 490.634 (56.21%) | 292.248 (33.48%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 755.152 | 248.451 (32.9%) | 537.181 (71.14%) | 302.875 (40.11%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 796.538 | 228.723 (28.71%) | 491.373 (61.69%) | 342.609 (43.01%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 828.639 | 274.785 (33.16%) | 557.601 (67.29%) | 341.393 (41.2%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 818.144 | 262.646 (32.1%) | 524.572 (64.12%) | 351.046 (42.91%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 599.255 | 191.374 (31.94%) | 416.723 (69.54%) | 214.748 (35.84%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 590.414 | 193.621 (32.79%) | 406.777 (68.9%) | 240.051 (40.66%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 606.763 | 218.096 (35.94%) | 395.387 (65.16%) | 240.114 (39.57%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 573.736 | 208.397 (36.32%) | 380.389 (66.3%) | 234.282 (40.83%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 654.577 | 204.519 (31.24%) | 372.8 (56.95%) | 227.904 (34.82%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 703.777 | 152.967 (21.74%) | 431.272 (61.28%) | 275.286 (39.12%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 739.801 | 237.956 (32.16%) | 400.672 (54.16%) | 278.539 (37.65%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 702.402 | 218.875 (31.16%) | 410.706 (58.47%) | 271.897 (38.71%) |
EishayParseTreeUTF8Bytes
这个是将UTF8格式的byte数组反序列化为JSONObject. 这个场景在fastjson中的代码如下:
byte[] utf8Bytes = ...;
JSONObject jsonObject = JSON.parseJSONObject(utf8Bytes);这个场景fastjson2同样表现出了卓越的性能;在JDK8下,fastjson1和jackson的性能分别之后fastjson2的50.49%和63.22%;
gson不直接支持输入utf8Bytes,需要先构造字符串,性能只有fastjson2的35%。
性能排序如下:
// ecs.c7.xlarge-oracle-jdk1.8.0_341_x64
fastjson2 > jackson > fastjson1 > gson
100% 63.22% 50.49% 35.5%下面是不同CPU不同JDK下的性能比较表格,第一列是阿里云机器规格和JDK的版本信息,第二列到第五列是JMH的Throughput数据,越大越好。
第三列到第五列中的百分比是Throughput相比fastjson2的比,比如第三列的百分比是fastjson1/fastjson2的百分数表示。
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 882.065 | 445.319 (50.49%) | 557.669 (63.22%) | 313.124 (35.5%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 654.899 | 360.26 (55.01%) | 514.301 (78.53%) | 315.332 (48.15%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 1044.966 | 478.063 (45.75%) | 568.644 (54.42%) | 321.917 (30.81%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1019.586 | 475.741 (46.66%) | 554.104 (54.35%) | 313.421 (30.74%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 724.629 | 426.142 (58.81%) | 572.952 (79.07%) | 328.595 (45.35%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 721.44 | 360.332 (49.95%) | 565.566 (78.39%) | 360.34 (49.95%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 852.787 | 452.351 (53.04%) | 606.124 (71.08%) | 392.469 (46.02%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 880.7 | 472.351 (53.63%) | 597.554 (67.85%) | 374.988 (42.58%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 532.788 | 249.575 (46.84%) | 441.72 (82.91%) | 240.525 (45.14%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 446.808 | 287.303 (64.3%) | 413.758 (92.6%) | 254.144 (56.88%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 590.05 | 317.036 (53.73%) | 456.912 (77.44%) | 253.741 (43%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 558.045 | 301.757 (54.07%) | 434.725 (77.9%) | 252.7 (45.28%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 501.696 | 253.89 (50.61%) | 372.582 (74.26%) | 242.819 (48.4%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 530.747 | 337.552 (63.6%) | 437.781 (82.48%) | 297.201 (56%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 771.518 | 348.721 (45.2%) | 507.337 (65.76%) | 275.168 (35.67%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 714.17 | 325.797 (45.62%) | 477.229 (66.82%) | 241.458 (33.81%) |
EishayParseTreeUTF8BytesPretty
这个是将格式化过后的UTF8格式的byte数组反序列化为JSONObject, 这个场景在fastjson中的代码如下:
// 这里输入的是格式化过后的json字符串
String str = "{\n" +
"\t\"id\":123\n" +
"}";
byte[] utf8Bytes = str.getBytes(StandardCharsets.UTF_8);
JSONObject jsonObject = JSON.parseJSONObject(utf8Bytes);这个场景fastjson2同样表现出了卓越的性能;在JDK8下,fastjson1和jackson的性能分别之后fastjson2的53.72%和70.22%,
gson不直接支持输入utf8Bytes,需要先构造字符串,性能只有fastjson2的41.25%。
性能排序如下:
// ecs.c7.xlarge-oracle-jdk1.8.0_341_x64
fastjson2 > jackson > fastjson1 > gson
100% 70.22% 53.72% 41.25%下面是不同CPU不同JDK下的性能比较表格,第一列是阿里云机器规格和JDK的版本信息,第二列到第五列是JMH的Throughput数据,越大越好。
第三列到第五列中的百分比是Throughput相比fastjson2的比,比如第三列的百分比是fastjson1/fastjson2的百分数表示。
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 716.744 | 385.002 (53.72%) | 503.301 (70.22%) | 295.637 (41.25%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 601.404 | 314.029 (52.22%) | 490.292 (81.52%) | 295.215 (49.09%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 851.286 | 411.4 (48.33%) | 512.209 (60.17%) | 293.605 (34.49%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 840.136 | 401.867 (47.83%) | 506.222 (60.25%) | 291.464 (34.69%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 635.907 | 366.566 (57.64%) | 516.876 (81.28%) | 301.97 (47.49%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 582.825 | 312.162 (53.56%) | 488.51 (83.82%) | 332.122 (56.98%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 682.302 | 381.257 (55.88%) | 547.474 (80.24%) | 364.789 (53.46%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 749.046 | 389.891 (52.05%) | 541.245 (72.26%) | 357.097 (47.67%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 466.952 | 220.237 (47.16%) | 402.868 (86.28%) | 220.594 (47.24%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 389.837 | 243.253 (62.4%) | 391.982 (100.55%) | 240.36 (61.66%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 499.026 | 273.415 (54.79%) | 406.731 (81.5%) | 236.56 (47.4%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 474.922 | 264.985 (55.8%) | 396.4 (83.47%) | 235.098 (49.5%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 471.287 | 234.086 (49.67%) | 344.737 (73.15%) | 230.781 (48.97%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 470.475 | 231.123 (49.13%) | 421.706 (89.63%) | 286.665 (60.93%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 622.918 | 250.837 (40.27%) | 441.649 (70.9%) | 279.948 (44.94%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 583.691 | 209.574 (35.9%) | 440.884 (75.53%) | 277.102 (47.47%) |
EishayWriteString
这个是Java对象序列化成字符串, 这个是最常用的场景之一。这个场景在fastjson中的代码如下:
Bean bean = ...;
String str = JSON.toJSONString(bean);性能排序如下:
// ecs.c7.xlarge-oracle-jdk1.8.0_341_x64
fastjson2 > jackson > fastjson1 > gson
100% 54.03% 37.61% 20.69%下面是不同CPU不同JDK下的性能比较表格,第一列是阿里云机器规格和JDK的版本信息,第二列到第五列是JMH的Throughput数据,越大越好。
第三列到第五列中的百分比是Throughput相比fastjson2的比,比如第三列的百分比是fastjson1/fastjson2的百分数表示。
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 1581.037 | 594.658 (37.61%) | 854.22 (54.03%) | 327.195 (20.69%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 1343.414 | 595.695 (44.34%) | 906.331 (67.46%) | 275.727 (20.52%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 1712.266 | 613.577 (35.83%) | 1001.97 (58.52%) | 205.201 (11.98%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1699.625 | 593.921 (34.94%) | 916.976 (53.95%) | 205.046 (12.06%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 1624.636 | 659.362 (40.59%) | 904.775 (55.69%) | 364.295 (22.42%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 1442.604 | 593.853 (41.17%) | 916.225 (63.51%) | 287.247 (19.91%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 1841.055 | 643.602 (34.96%) | 925.489 (50.27%) | 338.389 (18.38%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 1688.356 | 629.806 (37.3%) | 870.935 (51.58%) | 325.734 (19.29%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 1033.834 | 446.877 (43.23%) | 578.324 (55.94%) | 278.484 (26.94%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 1046.255 | 424.717 (40.59%) | 608.651 (58.17%) | 248.206 (23.72%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 1163.12 | 433.589 (37.28%) | 637.242 (54.79%) | 188.469 (16.2%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 1136.576 | 381.31 (33.55%) | 597.276 (52.55%) | 188.559 (16.59%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 1221.452 | 502.207 (41.12%) | 643.246 (52.66%) | 328.688 (26.91%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 1167.871 | 424.902 (36.38%) | 650.535 (55.7%) | 255.595 (21.89%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 1372.859 | 417.568 (30.42%) | 664.706 (48.42%) | 204.356 (14.89%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 1314.683 | 441.703 (33.6%) | 564.61 (42.95%) | 200.301 (15.24%) |
EishayWriteUTF8Bytes
这个是Java对象序列化成UTF格式的byte数组, 这个是最常用的场景之一,在缓存和RPC场景常用。gson不直接支持,需要先序列化为String再转换为UTF8格式的byte数组。
这个场景在fastjson中的代码如下:
Bean bean = ...;
byte[] utf8Bytes = JSON.toJSONBytes(bean);性能排序如下:
// ecs.c7.xlarge-oracle-jdk1.8.0_341_x64
fastjson2 > jackson > fastjson1 > gson
100% 59.13% 37.99% 19.52%下面是不同CPU不同JDK下的性能比较表格,第一列是阿里云机器规格和JDK的版本信息,第二列到第五列是JMH的Throughput数据,越大越好。
第三列到第五列中的百分比是Throughput相比fastjson2的比,比如第三列的百分比是fastjson1/fastjson2的百分数表示。
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 1504.496 | 571.509 (37.99%) | 889.578 (59.13%) | 293.743 (19.52%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 1592.624 | 507.917 (31.89%) | 854.436 (53.65%) | 276.88 (17.39%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 1856.092 | 570.574 (30.74%) | 969.387 (52.23%) | 202.302 (10.9%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1835.109 | 548.702 (29.9%) | 938.845 (51.16%) | 203.566 (11.09%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 1487.078 | 582.897 (39.2%) | 836.831 (56.27%) | 333.118 (22.4%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 1642.28 | 543.887 (33.12%) | 830.435 (50.57%) | 273.111 (16.63%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 1769.397 | 576.354 (32.57%) | 895.627 (50.62%) | 338.069 (19.11%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 1809.864 | 554.232 (30.62%) | 865.073 (47.8%) | 320.201 (17.69%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 1111.549 | 407.663 (36.68%) | 564.422 (50.78%) | 233.167 (20.98%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 1167.558 | 387.93 (33.23%) | 563.532 (48.27%) | 245.837 (21.06%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 1165.606 | 385.793 (33.1%) | 602.722 (51.71%) | 188.328 (16.16%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 1178.795 | 350.563 (29.74%) | 581.995 (49.37%) | 187.292 (15.89%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 1329.046 | 437.516 (32.92%) | 658.158 (49.52%) | 289.968 (21.82%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 1232.089 | 399.648 (32.44%) | 634.515 (51.5%) | 266.952 (21.67%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 1360.522 | 356.383 (26.19%) | 678.117 (49.84%) | 197.732 (14.53%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 1412.507 | 401.57 (28.43%) | 602.449 (42.65%) | 195.807 (13.86%) |
EishayWriteBinary
这个场景是将Java对象序列化为二进制的byte数组,是缓存序列化和RPC场景使用序列化协议的典型场景。
fastson2内置支持二进制格式jsonb,jsonb是fastjson2为了RPC场景设计的序列化和反序列化设置的高性能序列化协议。
jsonb有两种映射方式,将Java对象映射为类似JSONObject的KV格式,也可以映射类似JSONArray的数组格式。
fastjson2JSONBArrayMapping的代码如下:
Bean bean = ...;
byte[] jsonbBytes = JSONB.toBytes(bean, JSONWriter.Feature.BeanToArray);fastjson2JSONB的代码如下:
Bean bean = ...;
byte[] jsonbBytes = JSONB.toBytes(bean);fastjson2UTF8Bytes的代码如下:
Bean bean = ...;
byte[] utf8Bytes = JSON.toJSONBytes(bean);性能排序如下:
// ecs.c7.xlarge-oracle-jdk1.8.0_341_x64
fastjson2JSONBArrayMapping > fastjson2JSONB > kryo > fastjson2UTF8Bytes > hessian > javaSerialize
165.59% 100% 90.73% 71.59% 16.05% 10.37%下面是不同CPU不同JDK下的性能比较表格,第一列是阿里云机器规格和JDK的版本信息,第二列到第五列是JMH的Throughput数据,越大越好。
第三列到第五列中的百分比是Throughput相比fastjson2的比,比如第三列的百分比是fastjson1/fastjson2的百分数表示。
| fastjson2JSONB | fastjson2JSONBArrayMapping | fastjson2UTF8Bytes | hessian | javaSerialize | kryo | |
|---|---|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 2109.521 | 3492.913 (165.58%) | 1510.194 (71.59%) | 338.479 (16.05%) | 218.692 (10.37%) | 1913.902 (90.73%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 1832.584 | 3305.27 (180.36%) | 1587.198 (86.61%) | 327.303 (17.86%) | 204.381 (11.15%) | 1914.781 (104.49%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 2398.784 | 3445.758 (143.65%) | 1870.477 (77.98%) | 323.179 (13.47%) | 223.274 (9.31%) | 1875.871 (78.2%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 2631.992 | 4095.755 (155.61%) | 1821.928 (69.22%) | 317.838 (12.08%) | 241.661 (9.18%) | 1807.544 (68.68%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 1977.848 | 3205.618 (162.08%) | 1491.867 (75.43%) | 414.534 (20.96%) | 228.309 (11.54%) | 1761.061 (89.04%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 1986.387 | 3064.238 (154.26%) | 1696.878 (85.43%) | 389.741 (19.62%) | 242.035 (12.18%) | 1981.922 (99.78%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 1974.045 | 3129.304 (158.52%) | 1716.659 (86.96%) | 411.243 (20.83%) | 264.826 (13.42%) | 1790.338 (90.69%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 2385.79 | 4073.694 (170.75%) | 1742.115 (73.02%) | 409.094 (17.15%) | 260.802 (10.93%) | 1721.088 (72.14%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 1331.057 | 1885.63 (141.66%) | 1108.585 (83.29%) | 297.788 (22.37%) | 176.367 (13.25%) | 1107.134 (83.18%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 1476.657 | 2319.398 (157.07%) | 1159.41 (78.52%) | 322.343 (21.83%) | 189.048 (12.8%) | 1296.507 (87.8%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 1443.992 | 2228.329 (154.32%) | 1173.612 (81.28%) | 317.746 (22%) | 181.799 (12.59%) | 1230.239 (85.2%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 1608.314 | 2627.964 (163.4%) | 1165.379 (72.46%) | 312.327 (19.42%) | 195.064 (12.13%) | 1282.308 (79.73%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 1577.12 | 2362.358 (149.79%) | 1330.904 (84.39%) | 349.276 (22.15%) | 204.709 (12.98%) | 1431.816 (90.79%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 1774.645 | 2726.764 (153.65%) | 1360.397 (76.66%) | 340.869 (19.21%) | 218.516 (12.31%) | 1555.83 (87.67%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 1732.468 | 2463.208 (142.18%) | 1381.276 (79.73%) | 331.195 (19.12%) | 207.308 (11.97%) | 1439.65 (83.1%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 2004.688 | 3157.957 (157.53%) | 1417.265 (70.7%) | 332.99 (16.61%) | 224.267 (11.19%) | 1454.408 (72.55%) |
EishayParseBinary
这个场景是将二进制的byte数组反序列化为Java对象,是缓存序列化和RPC场景使用序列化协议的典型场景。
fastjson2JSONBArrayMapping的代码如下:
byte[] jsonbBytes = JSONB.toBytes(bean, JSONWriter.Feature.BeanToArray);
Bean bean = JSONB.parseObject(jsonbBytes, Bean.class, JSONReader.Feature.SupportArrayToBean);fastjson2JSONB的代码如下:
byte[] jsonbBytes = JSONB.toBytes(bean);
Bean bean = JSONB.parseObject(jsonbBytes, Bean.class);fastjson2UTF8Bytes的代码如下:
byte[] utf8Bytes = JSON.toJSONBytes(bean);
Bean bean = JSON.parseObject(utf8Bytes, Bean.class);性能排序如下:
// ecs.c7.xlarge-oracle-jdk1.8.0_341_x64
fastjson2JSONBArrayMapping > kryo > fastjson2JSONB > fastjson2UTF8Bytes > hessian > javaSerialize
153.96% 100%.25% 100% 67.16% 16.83% 2.84%下面是不同CPU不同JDK下的性能比较表格,第一列是阿里云机器规格和JDK的版本信息,第二列到第五列是JMH的Throughput数据,越大越好。
第三列到第五列中的百分比是Throughput相比fastjson2的比,比如第三列的百分比是fastjson1/fastjson2的百分数表示。
| fastjson2JSONB | fastjson2JSONBArrayMapping | fastjson2UTF8Bytes | hessian | javaSerialize | kryo | |
|---|---|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 1648.648 | 2538.226 (153.96%) | 1107.184 (67.16%) | 277.395 (16.83%) | 46.794 (2.84%) | 1652.73 (100.25%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 2178.064 | 3546.334 (162.82%) | 1141.561 (52.41%) | 248.849 (11.43%) | 48.114 (2.21%) | 1706.163 (78.33%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 2210.446 | 3581.414 (162.02%) | 1240.231 (56.11%) | 257.332 (11.64%) | 52.042 (2.35%) | 1499.663 (67.84%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 2208.152 | 3733.627 (169.08%) | 1201.981 (54.43%) | 246.276 (11.15%) | 51.45 (2.33%) | 1633.479 (73.97%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 1293.382 | 1745.828 (134.98%) | 929.428 (71.86%) | 255.801 (19.78%) | 43.298 (3.35%) | 1446.488 (111.84%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 2067.736 | 3332.012 (161.14%) | 1058.228 (51.18%) | 243.973 (11.8%) | 47.149 (2.28%) | 1554.486 (75.18%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 2223.355 | 3609.628 (162.35%) | 1120.472 (50.4%) | 250.796 (11.28%) | 53.126 (2.39%) | 1623.24 (73.01%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 2114.786 | 3522.422 (166.56%) | 1126.199 (53.25%) | 246.965 (11.68%) | 51.824 (2.45%) | 1644.455 (77.76%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 1256.386 | 2110.098 (167.95%) | 730.412 (58.14%) | 190.884 (15.19%) | 36.785 (2.93%) | 1300.187 (103.49%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 1418.018 | 2542.738 (179.32%) | 756.803 (53.37%) | 179.716 (12.67%) | 37.508 (2.65%) | 1242.747 (87.64%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 1303.159 | 2187.211 (167.84%) | 761.374 (58.43%) | 208.406 (15.99%) | 39.672 (3.04%) | 1223.11 (93.86%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 1271.578 | 2163.511 (170.14%) | 719.966 (56.62%) | 187.4 (14.74%) | 37.463 (2.95%) | 1189.698 (93.56%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 1270.914 | 2272.559 (178.81%) | 816.239 (64.22%) | 200.373 (15.77%) | 42.276 (3.33%) | 1191.146 (93.72%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 1811.452 | 3101.861 (171.24%) | 982.786 (54.25%) | 200.661 (11.08%) | 40.634 (2.24%) | 1413.636 (78.04%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 1644.118 | 2692.082 (163.74%) | 989.303 (60.17%) | 156.648 (9.53%) | 40.901 (2.49%) | 1090.731 (66.34%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 1630.171 | 2673.894 (164.03%) | 938.366 (57.56%) | 201.279 (12.35%) | 42.244 (2.59%) | 1222.099 (74.97%) |
Benchmark Benchmark 2.0.12 01 (`docs/benchmark/benchmark_2.0.12_01.md`)
EishayParseBinary
| fastjson2JSONB | fastjson2UTF8Bytes | hessian | javaSerialize | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 1593.884 | 1115.913 (70.01%) | 294.53 (18.48%) | 47.721 (2.99%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 2156.711 | 1126.378 (52.23%) | 249.719 (11.58%) | 49.622 (2.3%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 2141.289 | 1251.953 (58.47%) | 259.265 (12.11%) | 50.116 (2.34%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 1284.022 | 928.894 (72.34%) | 263.156 (20.49%) | 44.473 (3.46%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 2053.849 | 1067.43 (51.97%) | 248.478 (12.1%) | 46.725 (2.27%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 2036.356 | 1122.836 (55.14%) | 251.768 (12.36%) | 52.786 (2.59%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 1251.423 | 726.682 (58.07%) | 191.391 (15.29%) | 37.079 (2.96%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1427.546 | 759.282 (53.19%) | 179.963 (12.61%) | 35.548 (2.49%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1304.103 | 773.739 (59.33%) | 187.23 (14.36%) | 38.024 (2.92%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 1344.742 | 843.793 (62.75%) | 210.495 (15.65%) | 43.046 (3.2%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1799.585 | 983.652 (54.66%) | 185.482 (10.31%) | 39.232 (2.18%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1640.66 | 978.838 (59.66%) | 204.519 (12.47%) | 41.055 (2.5%) |
EishayParseString
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 1243.83 | 1033.629 (83.1%) | 536.725 (43.15%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 1157.766 | 907.446 (78.38%) | 480.823 (41.53%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 1216.273 | 1261.329 (103.7%) | 504.882 (41.51%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 1177.961 | 1036.569 (88%) | 540.255 (45.86%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 1122.48 | 929.277 (82.79%) | 480.362 (42.79%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 1154.419 | 1261.925 (109.31%) | 523.665 (45.36%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 814.151 | 730.259 (89.7%) | 381.449 (46.85%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 784.716 | 737.326 (93.96%) | 370.102 (47.16%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 792.361 | 1019.615 (128.68%) | 375.324 (47.37%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 950.365 | 840.18 (88.41%) | 387.823 (40.81%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 999.693 | 799.336 (79.96%) | 411.314 (41.14%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 964.72 | 961.082 (99.62%) | 427.146 (44.28%) |
EishayParseStringPretty
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 940.621 | 267.296 (28.42%) | 493.035 (52.42%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 852.584 | 238.875 (28.02%) | 434.496 (50.96%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 911.369 | 291.129 (31.94%) | 472.871 (51.89%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 905.501 | 277.512 (30.65%) | 470.058 (51.91%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 753.702 | 253.62 (33.65%) | 444.096 (58.92%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 838.209 | 307.535 (36.69%) | 483.185 (57.64%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 648.056 | 209.206 (32.28%) | 347.135 (53.57%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 618.992 | 213.93 (34.56%) | 343.126 (55.43%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 622.208 | 242.946 (39.05%) | 354.941 (57.05%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 735.12 | 224.895 (30.59%) | 363.791 (49.49%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 727.684 | 216.845 (29.8%) | 366.807 (50.41%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 725.653 | 251.436 (34.65%) | 386.445 (53.25%) |
EishayParseTreeString
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 956.628 | 519.549 (54.31%) | 523.461 (54.72%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 777.685 | 405.606 (52.16%) | 451.435 (58.05%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 1031.264 | 545.64 (52.91%) | 500.669 (48.55%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 844.62 | 474.123 (56.13%) | 545.199 (64.55%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 787.826 | 418.608 (53.13%) | 409.345 (51.96%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 968.653 | 515.549 (53.22%) | 529.034 (54.62%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 558.526 | 304.239 (54.47%) | 354.217 (63.42%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 522.565 | 321.931 (61.61%) | 352.447 (67.45%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 587.78 | 360.224 (61.29%) | 380.51 (64.74%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 600.355 | 302.597 (50.4%) | 344.151 (57.32%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 634.662 | 365.34 (57.56%) | 383.903 (60.49%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 757.55 | 414.411 (54.7%) | 423.246 (55.87%) |
EishayParseTreeStringPretty
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 751.19 | 436.834 (58.15%) | 487.063 (64.84%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 643.119 | 344.993 (53.64%) | 406.014 (63.13%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 803.816 | 473.683 (58.93%) | 454.547 (56.55%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 693.473 | 424.979 (61.28%) | 486.887 (70.21%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 628.151 | 354.2 (56.39%) | 426.899 (67.96%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 658.592 | 478.701 (72.69%) | 517.626 (78.6%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 481.516 | 270.386 (56.15%) | 329.991 (68.53%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 443.296 | 275.338 (62.11%) | 328.534 (74.11%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 489.754 | 311.54 (63.61%) | 346.172 (70.68%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 512.832 | 299.877 (58.47%) | 324.0 (63.18%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 529.142 | 282.596 (53.41%) | 355.726 (67.23%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 607.546 | 366.248 (60.28%) | 394.522 (64.94%) |
EishayParseTreeUTF8Bytes
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 842.058 | 450.222 (53.47%) | 596.172 (70.8%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 675.988 | 352.657 (52.17%) | 510.722 (75.55%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 1046.149 | 484.344 (46.3%) | 568.08 (54.3%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 716.802 | 426.156 (59.45%) | 604.379 (84.32%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 721.752 | 363.024 (50.3%) | 522.058 (72.33%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 805.28 | 453.63 (56.33%) | 621.125 (77.13%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 532.631 | 248.887 (46.73%) | 438.97 (82.42%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 461.63 | 286.343 (62.03%) | 413.093 (89.49%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 589.818 | 321.691 (54.54%) | 444.596 (75.38%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 555.658 | 271.985 (48.95%) | 408.457 (73.51%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 558.793 | 318.917 (57.07%) | 433.975 (77.66%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 765.39 | 355.383 (46.43%) | 498.031 (65.07%) |
EishayParseTreeUTF8BytesPretty
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 725.945 | 373.116 (51.4%) | 535.071 (73.71%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 602.86 | 312.32 (51.81%) | 482.013 (79.95%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 883.409 | 409.415 (46.34%) | 513.15 (58.09%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 607.495 | 353.426 (58.18%) | 517.267 (85.15%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 582.043 | 306.307 (52.63%) | 471.013 (80.92%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 678.833 | 389.333 (57.35%) | 549.875 (81%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 471.283 | 222.012 (47.11%) | 403.433 (85.6%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 391.833 | 241.895 (61.73%) | 382.095 (97.51%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 499.826 | 272.086 (54.44%) | 415.048 (83.04%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 491.159 | 241.898 (49.25%) | 366.433 (74.61%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 480.579 | 225.799 (46.98%) | 413.264 (85.99%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 626.26 | 252.012 (40.24%) | 445.107 (71.07%) |
EishayParseUTF8Bytes
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 1115.788 | 824.52 (73.9%) | 633.6 (56.78%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 1148.37 | 746.624 (65.02%) | 558.297 (48.62%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 1197.433 | 953.389 (79.62%) | 554.686 (46.32%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 913.559 | 796.013 (87.13%) | 616.299 (67.46%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 1070.144 | 700.649 (65.47%) | 581.561 (54.34%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 1126.364 | 958.283 (85.08%) | 603.544 (53.58%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 722.122 | 572.492 (79.28%) | 454.138 (62.89%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 752.972 | 579.819 (77%) | 434.358 (57.69%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 765.737 | 760.291 (99.29%) | 433.94 (56.67%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 852.96 | 688.664 (80.74%) | 435.846 (51.1%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 946.306 | 672.865 (71.1%) | 472.545 (49.94%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 973.199 | 771.305 (79.25%) | 367.461 (37.76%) |
EishayParseUTF8BytesPretty
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 812.283 | 250.143 (30.8%) | 553.829 (68.18%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 821.754 | 219.988 (26.77%) | 501.893 (61.08%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 909.504 | 270.964 (29.79%) | 513.334 (56.44%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 727.288 | 251.173 (34.54%) | 547.337 (75.26%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 792.656 | 232.404 (29.32%) | 501.099 (63.22%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 829.454 | 267.905 (32.3%) | 536.34 (64.66%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 600.074 | 191.401 (31.9%) | 419.744 (69.95%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 595.138 | 192.514 (32.35%) | 397.109 (66.73%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 604.655 | 217.012 (35.89%) | 397.37 (65.72%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 680.242 | 211.318 (31.07%) | 404.126 (59.41%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 734.482 | 143.241 (19.5%) | 424.415 (57.78%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 731.491 | 242.766 (33.19%) | 422.426 (57.75%) |
EishayWriteBinary
| fastjson2JSONB | fastjson2UTF8Bytes | hessian | javaSerialize | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 2100.5 | 1500.893 (71.45%) | 343.98 (16.38%) | 219.502 (10.45%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 1749.004 | 1593.138 (91.09%) | 335.663 (19.19%) | 212.141 (12.13%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 2282.267 | 1878.427 (82.31%) | 321.187 (14.07%) | 216.51 (9.49%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 1975.557 | 1428.835 (72.33%) | 400.24 (20.26%) | 230.517 (11.67%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 2024.133 | 1709.225 (84.44%) | 385.566 (19.05%) | 234.368 (11.58%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 1995.572 | 1764.191 (88.41%) | 394.86 (19.79%) | 260.833 (13.07%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 1327.324 | 1107.706 (83.45%) | 288.837 (21.76%) | 178.746 (13.47%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1478.625 | 1161.899 (78.58%) | 326.657 (22.09%) | 186.735 (12.63%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1447.849 | 1168.93 (80.74%) | 313.401 (21.65%) | 178.478 (12.33%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 1600.041 | 1339.271 (83.7%) | 346.376 (21.65%) | 208.976 (13.06%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1760.602 | 1363.921 (77.47%) | 348.116 (19.77%) | 213.959 (12.15%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1497.969 | 1377.998 (91.99%) | 349.442 (23.33%) | 207.95 (13.88%) |
EishayWriteString
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 1608.824 | 602.23 (37.43%) | 991.367 (61.62%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 1347.512 | 579.278 (42.99%) | 940.192 (69.77%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 1734.118 | 611.058 (35.24%) | 1025.962 (59.16%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 1520.574 | 639.442 (42.05%) | 962.835 (63.32%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 1385.516 | 651.116 (46.99%) | 933.002 (67.34%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 1821.129 | 636.012 (34.92%) | 971.605 (53.35%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 1046.272 | 421.828 (40.32%) | 573.985 (54.86%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1041.772 | 436.603 (41.91%) | 620.684 (59.58%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1165.94 | 470.706 (40.37%) | 629.092 (53.96%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 1185.044 | 524.936 (44.3%) | 666.35 (56.23%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1200.772 | 281.255 (23.42%) | 667.646 (55.6%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1363.704 | 441.652 (32.39%) | 683.959 (50.15%) |
EishayWriteUTF8Bytes
| fastjson2 | fastjson1 | jackson | |
|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 1521.258 | 575.263 (37.81%) | 923.559 (60.71%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 1589.072 | 526.388 (33.13%) | 837.807 (52.72%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 1895.835 | 547.198 (28.86%) | 965.059 (50.9%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 1482.973 | 564.045 (38.03%) | 852.789 (57.51%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 1771.827 | 552.918 (31.21%) | 838.326 (47.31%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 1784.106 | 578.738 (32.44%) | 901.058 (50.5%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 1111.935 | 428.527 (38.54%) | 582.077 (52.35%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1165.546 | 428.039 (36.72%) | 539.294 (46.27%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1173.999 | 417.296 (35.54%) | 608.457 (51.83%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 1323.506 | 459.148 (34.69%) | 682.008 (51.53%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1003.478 | 448.487 (44.69%) | 464.68 (46.31%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1387.463 | 503.475 (36.29%) | 670.261 (48.31%) |
Benchmark Benchmark 2.0.12 02 (`docs/benchmark/benchmark_2.0.12_02.md`)
EishayParseBinary
| fastjson2JSONB | fastjson2JSONBArrayMapping | fastjson2UTF8Bytes | hessian | javaSerialize | kryo | |
|---|---|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 1668.106 | 2531.075 (151.73%) | 1113.3 (66.74%) | 286.462 (17.17%) | 46.624 (2.8%) | 1760.753 (105.55%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 2112.117 | 3551.955 (168.17%) | 1122.916 (53.17%) | 249.439 (11.81%) | 48.984 (2.32%) | 1664.911 (78.83%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 2156.103 | 3686.524 (170.98%) | 1183.409 (54.89%) | 259.408 (12.03%) | 50.35 (2.34%) | 1701.72 (78.93%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 1268.149 | 1732.627 (136.63%) | 933.027 (73.57%) | 269.004 (21.21%) | 43.412 (3.42%) | 1602.908 (126.4%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 2029.297 | 3259.735 (160.63%) | 1107.77 (54.59%) | 248.523 (12.25%) | 47.521 (2.34%) | 1588.697 (78.29%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 2131.388 | 3576.604 (167.81%) | 1128.695 (52.96%) | 248.131 (11.64%) | 52.257 (2.45%) | 1673.96 (78.54%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 1250.949 | 2117.129 (169.24%) | 727.892 (58.19%) | 191.299 (15.29%) | 37.688 (3.01%) | 1295.504 (103.56%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1425.163 | 2532.095 (177.67%) | 760.246 (53.34%) | 180.246 (12.65%) | 35.625 (2.5%) | 1242.294 (87.17%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1302.965 | 2174.417 (166.88%) | 760.838 (58.39%) | 206.534 (15.85%) | 38.969 (2.99%) | 1236.211 (94.88%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 1218.671 | 2251.518 (184.75%) | 807.741 (66.28%) | 203.042 (16.66%) | 42.838 (3.52%) | 1201.842 (98.62%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1804.612 | 3078.593 (170.6%) | 935.944 (51.86%) | 201.146 (11.15%) | 39.761 (2.2%) | 1344.932 (74.53%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1645.389 | 2711.132 (164.77%) | 977.844 (59.43%) | 192.384 (11.69%) | 35.786 (2.17%) | 1119.833 (68.06%) |
EishayParseString
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 1290.95 | 1034.527 (80.14%) | 546.46 (42.33%) | 447.926 (34.7%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 1195.518 | 910.746 (76.18%) | 507.302 (42.43%) | 439.436 (36.76%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 1296.254 | 1260.522 (97.24%) | 510.198 (39.36%) | 457.559 (35.3%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 1252.083 | 1022.568 (81.67%) | 527.586 (42.14%) | 444.198 (35.48%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 1093.434 | 937.143 (85.71%) | 462.637 (42.31%) | 464.603 (42.49%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 1223.115 | 1303.72 (106.59%) | 535.477 (43.78%) | 535.809 (43.81%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 843.131 | 731.306 (86.74%) | 380.996 (45.19%) | 313.538 (37.19%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 830.9 | 733.788 (88.31%) | 370.081 (44.54%) | 322.413 (38.8%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 851.539 | 1025.157 (120.39%) | 384.009 (45.1%) | 317.713 (37.31%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 909.044 | 757.368 (83.31%) | 378.9 (41.68%) | 340.069 (37.41%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1017.078 | 814.31 (80.06%) | 420.444 (41.34%) | 383.502 (37.71%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1042.751 | 1116.179 (107.04%) | 432.825 (41.51%) | 326.67 (31.33%) |
EishayParseStringPretty
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 932.954 | 268.644 (28.79%) | 503.244 (53.94%) | 420.283 (45.05%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 886.296 | 242.163 (27.32%) | 457.38 (51.61%) | 401.352 (45.28%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 972.604 | 301.482 (31%) | 461.692 (47.47%) | 408.493 (42%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 938.535 | 274.271 (29.22%) | 451.827 (48.14%) | 427.904 (45.59%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 805.992 | 257.218 (31.91%) | 443.054 (54.97%) | 439.631 (54.55%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 869.271 | 302.006 (34.74%) | 484.644 (55.75%) | 468.961 (53.95%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 670.757 | 207.566 (30.95%) | 350.297 (52.22%) | 283.328 (42.24%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 646.858 | 210.173 (32.49%) | 348.626 (53.9%) | 296.149 (45.78%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 658.367 | 241.997 (36.76%) | 352.707 (53.57%) | 295.035 (44.81%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 725.003 | 218.725 (30.17%) | 345.966 (47.72%) | 324.484 (44.76%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 763.574 | 218.014 (28.55%) | 374.728 (49.08%) | 349.551 (45.78%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 749.342 | 269.82 (36.01%) | 390.461 (52.11%) | 316.391 (42.22%) |
EishayParseTreeString
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 974.443 | 518.073 (53.17%) | 521.191 (53.49%) | 345.331 (35.44%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 770.039 | 404.122 (52.48%) | 432.257 (56.13%) | 324.563 (42.15%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 1062.454 | 545.812 (51.37%) | 510.375 (48.04%) | 313.54 (29.51%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 862.193 | 481.507 (55.85%) | 531.252 (61.62%) | 367.791 (42.66%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 797.846 | 407.363 (51.06%) | 482.303 (60.45%) | 365.989 (45.87%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 994.037 | 535.625 (53.88%) | 524.506 (52.77%) | 372.054 (37.43%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 576.441 | 306.931 (53.25%) | 357.5 (62.02%) | 258.568 (44.86%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 535.397 | 322.644 (60.26%) | 353.783 (66.08%) | 260.914 (48.73%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 608.868 | 361.341 (59.35%) | 374.923 (61.58%) | 257.151 (42.23%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 566.97 | 312.493 (55.12%) | 324.081 (57.16%) | 252.538 (44.54%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 657.677 | 357.505 (54.36%) | 374.169 (56.89%) | 306.107 (46.54%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 765.412 | 410.072 (53.58%) | 431.9 (56.43%) | 293.941 (38.4%) |
EishayParseTreeStringPretty
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 780.274 | 450.684 (57.76%) | 472.136 (60.51%) | 331.779 (42.52%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 649.987 | 342.913 (52.76%) | 411.218 (63.27%) | 308.424 (47.45%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 790.833 | 478.099 (60.46%) | 467.633 (59.13%) | 298.418 (37.73%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 727.84 | 419.628 (57.65%) | 463.483 (63.68%) | 344.371 (47.31%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 656.439 | 353.404 (53.84%) | 408.744 (62.27%) | 353.705 (53.88%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 746.735 | 463.323 (62.05%) | 477.17 (63.9%) | 372.815 (49.93%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 491.422 | 267.261 (54.39%) | 327.88 (66.72%) | 243.463 (49.54%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 457.604 | 273.113 (59.68%) | 321.2 (70.19%) | 245.897 (53.74%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 502.792 | 310.015 (61.66%) | 352.529 (70.11%) | 246.235 (48.97%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 483.462 | 277.79 (57.46%) | 306.08 (63.31%) | 257.394 (53.24%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 548.725 | 287.047 (52.31%) | 327.783 (59.74%) | 291.182 (53.07%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 620.298 | 370.226 (59.69%) | 398.305 (64.21%) | 196.468 (31.67%) |
EishayParseTreeUTF8Bytes
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 862.961 | 452.779 (52.47%) | 592.957 (68.71%) | 323.504 (37.49%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 638.387 | 357.875 (56.06%) | 512.237 (80.24%) | 316.142 (49.52%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 1049.793 | 478.187 (45.55%) | 544.032 (51.82%) | 319.615 (30.45%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 710.754 | 423.429 (59.57%) | 614.455 (86.45%) | 337.896 (47.54%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 699.941 | 359.779 (51.4%) | 551.925 (78.85%) | 352.729 (50.39%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 804.949 | 470.259 (58.42%) | 597.45 (74.22%) | 387.864 (48.18%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 533.294 | 247.999 (46.5%) | 437.341 (82.01%) | 233.58 (43.8%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 444.204 | 285.797 (64.34%) | 425.116 (95.7%) | 254.241 (57.24%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 589.561 | 321.926 (54.6%) | 450.585 (76.43%) | 253.213 (42.95%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 507.982 | 255.876 (50.37%) | 383.079 (75.41%) | 243.392 (47.91%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 527.424 | 303.063 (57.46%) | 446.222 (84.6%) | 288.116 (54.63%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 755.745 | 312.584 (41.36%) | 498.081 (65.91%) | 286.295 (37.88%) |
EishayParseTreeUTF8BytesPretty
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 727.29 | 381.495 (52.45%) | 543.565 (74.74%) | 299.028 (41.12%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 583.368 | 319.15 (54.71%) | 476.652 (81.71%) | 305.22 (52.32%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 872.267 | 404.152 (46.33%) | 502.609 (57.62%) | 296.751 (34.02%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 633.819 | 362.68 (57.22%) | 522.966 (82.51%) | 310.062 (48.92%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 591.25 | 313.5 (53.02%) | 500.127 (84.59%) | 338.44 (57.24%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 677.69 | 400.262 (59.06%) | 557.901 (82.32%) | 351.684 (51.89%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 471.694 | 217.544 (46.12%) | 401.936 (85.21%) | 220.725 (46.79%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 388.983 | 245.07 (63%) | 387.355 (99.58%) | 240.521 (61.83%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 499.989 | 275.665 (55.13%) | 414.253 (82.85%) | 235.844 (47.17%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 465.484 | 231.83 (49.8%) | 354.087 (76.07%) | 235.597 (50.61%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 469.057 | 259.251 (55.27%) | 418.669 (89.26%) | 281.646 (60.05%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 629.0 | 224.691 (35.72%) | 449.036 (71.39%) | 277.953 (44.19%) |
EishayParseUTF8Bytes
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 1081.695 | 820.265 (75.83%) | 618.457 (57.17%) | 317.204 (29.32%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 1113.731 | 759.542 (68.2%) | 545.306 (48.96%) | 303.667 (27.27%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 1208.173 | 949.47 (78.59%) | 563.511 (46.64%) | 316.157 (26.17%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 920.333 | 805.007 (87.47%) | 624.926 (67.9%) | 340.036 (36.95%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 1094.745 | 718.199 (65.6%) | 569.395 (52.01%) | 366.12 (33.44%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 1135.271 | 907.606 (79.95%) | 627.577 (55.28%) | 381.164 (33.57%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 724.305 | 573.987 (79.25%) | 453.338 (62.59%) | 240.232 (33.17%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 747.67 | 592.082 (79.19%) | 431.072 (57.66%) | 253.961 (33.97%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 765.502 | 760.074 (99.29%) | 436.837 (57.07%) | 253.281 (33.09%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 786.174 | 665.469 (84.65%) | 423.816 (53.91%) | 240.501 (30.59%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 951.018 | 675.263 (71%) | 469.014 (49.32%) | 299.045 (31.44%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 905.464 | 664.684 (73.41%) | 442.049 (48.82%) | 254.591 (28.12%) |
EishayParseUTF8BytesPretty
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 816.229 | 251.275 (30.78%) | 558.575 (68.43%) | 301.126 (36.89%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 827.361 | 229.352 (27.72%) | 488.055 (58.99%) | 299.599 (36.21%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 921.053 | 273.037 (29.64%) | 500.907 (54.38%) | 307.902 (33.43%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 755.288 | 252.162 (33.39%) | 547.119 (72.44%) | 310.978 (41.17%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 756.057 | 228.471 (30.22%) | 525.199 (69.47%) | 345.609 (45.71%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 829.032 | 272.84 (32.91%) | 566.582 (68.34%) | 357.701 (43.15%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 599.814 | 190.016 (31.68%) | 412.91 (68.84%) | 221.181 (36.87%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 591.149 | 193.106 (32.67%) | 400.876 (67.81%) | 239.961 (40.59%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 601.959 | 216.469 (35.96%) | 392.47 (65.2%) | 238.428 (39.61%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 666.174 | 207.079 (31.08%) | 380.219 (57.08%) | 225.818 (33.9%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 734.141 | 159.535 (21.73%) | 428.554 (58.37%) | 284.688 (38.78%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 745.716 | 246.627 (33.07%) | 311.13 (41.72%) | 285.566 (38.29%) |
EishayWriteBinary
| fastjson2JSONB | fastjson2JSONBArrayMapping | fastjson2UTF8Bytes | hessian | javaSerialize | kryo | |
|---|---|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 2102.315 | 3591.233 (170.82%) | 1511.416 (71.89%) | 336.296 (16%) | 228.311 (10.86%) | 1876.677 (89.27%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 1790.531 | 3181.697 (177.7%) | 1567.147 (87.52%) | 335.033 (18.71%) | 209.731 (11.71%) | 1937.436 (108.2%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 2270.396 | 3495.588 (153.96%) | 1854.709 (81.69%) | 324.832 (14.31%) | 212.496 (9.36%) | 1835.352 (80.84%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 1963.183 | 3201.282 (163.07%) | 1417.174 (72.19%) | 407.761 (20.77%) | 236.601 (12.05%) | 1742.396 (88.75%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 2026.764 | 3072.586 (151.6%) | 1673.021 (82.55%) | 402.157 (19.84%) | 234.711 (11.58%) | 1981.097 (97.75%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 1989.658 | 3134.892 (157.56%) | 1776.469 (89.29%) | 412.577 (20.74%) | 253.303 (12.73%) | 1733.703 (87.14%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 1330.155 | 1897.064 (142.62%) | 1105.824 (83.13%) | 297.233 (22.35%) | 182.094 (13.69%) | 1100.244 (82.72%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1481.296 | 2327.613 (157.13%) | 1159.19 (78.26%) | 324.987 (21.94%) | 189.456 (12.79%) | 1306.303 (88.19%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1443.791 | 2236.365 (154.9%) | 1173.25 (81.26%) | 316.261 (21.9%) | 184.816 (12.8%) | 1233.29 (85.42%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 1579.625 | 2366.819 (149.83%) | 1331.639 (84.3%) | 358.127 (22.67%) | 207.135 (13.11%) | 1423.271 (90.1%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1756.044 | 2699.568 (153.73%) | 1374.166 (78.25%) | 341.339 (19.44%) | 220.062 (12.53%) | 1536.523 (87.5%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1732.592 | 2499.224 (144.25%) | 1390.66 (80.26%) | 332.098 (19.17%) | 202.391 (11.68%) | 1398.894 (80.74%) |
EishayWriteString
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 1608.27 | 603.863 (37.55%) | 1007.5 (62.64%) | 336.967 (20.95%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 1354.011 | 580.552 (42.88%) | 927.142 (68.47%) | 278.345 (20.56%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 1742.544 | 618.511 (35.49%) | 1024.775 (58.81%) | 206.788 (11.87%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 1636.958 | 634.6 (38.77%) | 970.449 (59.28%) | 364.018 (22.24%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 1452.748 | 655.453 (45.12%) | 922.089 (63.47%) | 271.137 (18.66%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 1811.883 | 675.066 (37.26%) | 947.629 (52.3%) | 342.228 (18.89%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 1048.059 | 452.449 (43.17%) | 582.368 (55.57%) | 279.83 (26.7%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1077.321 | 474.75 (44.07%) | 613.425 (56.94%) | 244.524 (22.7%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1176.606 | 446.515 (37.95%) | 639.637 (54.36%) | 189.864 (16.14%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 1222.683 | 498.235 (40.75%) | 652.259 (53.35%) | 329.624 (26.96%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1087.556 | 386.313 (35.52%) | 544.952 (50.11%) | 305.655 (28.1%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1205.87 | 433.724 (35.97%) | 679.291 (56.33%) | 206.127 (17.09%) |
EishayWriteUTF8Bytes
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_333_x64 | 1504.287 | 568.315 (37.78%) | 911.66 (60.6%) | 295.234 (19.63%) |
| ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64 | 1609.876 | 527.45 (32.76%) | 843.493 (52.39%) | 271.66 (16.87%) |
| ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64 | 1897.479 | 559.289 (29.48%) | 961.993 (50.7%) | 206.01 (10.86%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64 | 1507.623 | 580.789 (38.52%) | 828.977 (54.99%) | 327.916 (21.75%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64 | 1706.533 | 571.429 (33.48%) | 830.484 (48.66%) | 285.567 (16.73%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64 | 1818.65 | 586.322 (32.24%) | 850.341 (46.76%) | 336.466 (18.5%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64 | 1132.914 | 409.958 (36.19%) | 572.569 (50.54%) | 235.601 (20.8%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1163.252 | 390.414 (33.56%) | 554.953 (47.71%) | 242.863 (20.88%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1171.187 | 390.932 (33.38%) | 601.488 (51.36%) | 187.236 (15.99%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64 | 1311.633 | 463.696 (35.35%) | 656.142 (50.02%) | 285.337 (21.75%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64 | 1345.075 | 419.077 (31.16%) | 601.329 (44.71%) | 308.569 (22.94%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64 | 1377.142 | 440.872 (32.01%) | 642.213 (46.63%) | 205.429 (14.92%) |
Benchmark Benchmark 2.0.12 Raw (`docs/benchmark/benchmark_2.0.12_raw.md`)
ecs.c7.xlarge-oracle-jdk1.8.0_341_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7.xlarge-oracle-jdk-11.0.16_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7.xlarge-oracle-jdk-17.0.4_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7.xlarge-oracle-jdk-18.0.2_x6
/* Detailed source-code truncated for AI context efficiency. */ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7a.xlarge-oracle-jdk-11.0.16_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7a.xlarge-oracle-jdk-17.0.4_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7a.xlarge-oracle-jdk-18.0.2_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64
/* Detailed source-code truncated for AI context efficiency. */Benchmark Benchmark 2.0.12 Raw01 (`docs/benchmark/benchmark_2.0.12_raw01.md`)
ecs.c7.xlarge-oracle-jdk1.8.0_333_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64
/* Detailed source-code truncated for AI context efficiency. */Benchmark Benchmark 2.0.12 Raw02 (`docs/benchmark/benchmark_2.0.12_raw02.md`)
ecs.c7.xlarge-oracle-jdk1.8.0_333_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7.xlarge-oracle-jdk-11.0.15.1_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7.xlarge-oracle-jdk-17.0.3.1_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7a.xlarge-oracle-jdk1.8.0_333_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7a.xlarge-oracle-jdk-11.0.15.1_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c7a.xlarge-oracle-jdk-17.0.3.1_x64
/* Detailed source-code truncated for AI context efficiency. */ecs.c6r.xlarge-oracle-jdk1.8.0_333_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.c6r.xlarge-oracle-jdk-11.0.15.1_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.c6r.xlarge-oracle-jdk-17.0.3.1_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.g8m.xlarge-oracle-jdk1.8.0_333_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.g8m.xlarge-oracle-jdk-11.0.15.1_aarch64
/* Detailed source-code truncated for AI context efficiency. */ecs.g8m.xlarge-oracle-jdk-17.0.3.1_aarch64
/* Detailed source-code truncated for AI context efficiency. */Benchmark Benchmark 2.0.13 (`docs/benchmark/benchmark_2.0.13.md`)
EishayParseBinary
| aliyun ecs spec | jdk version | fastjson2JSONB | fastjson2UTF8Bytes | hessian | javaSerialize |
|---|---|---|---|---|---|
| ecs.c7.xlarge | oracle-jdk1.8.0_341_x64 | 1649.494 | 1103.643 (66.91%) | 277.963 (16.85%) | 46.566 (2.82%) |
| ecs.c7.xlarge | oracle-jdk-11.0.16_x64 | 2438.929 | 1143.151 (46.87%) | 248.418 (10.19%) | 48.052 (1.97%) |
| ecs.c7.xlarge | oracle-jdk-17.0.4_x64 | 2939.697 | 1260.484 (42.88%) | 258.96 (8.81%) | 54.268 (1.85%) |
| ecs.c7.xlarge | oracle-jdk-18.0.2_x64 | 2836.159 | 1272.521 (44.87%) | 244.107 (8.61%) | 51.249 (1.81%) |
| ecs.c7a.xlarge | oracle-jdk1.8.0_341_x64 | 1726.105 | 1073.354 (62.18%) | 268.816 (15.57%) | 46.993 (2.72%) |
| ecs.c7a.xlarge | oracle-jdk-11.0.16_x64 | 2478.146 | 1144.019 (46.16%) | 245.967 (9.93%) | 47.449 (1.91%) |
| ecs.c7a.xlarge | oracle-jdk-17.0.4_x64 | 2795.659 | 1082.007 (38.7%) | 251.527 (9%) | 52.396 (1.87%) |
| ecs.c7a.xlarge | oracle-jdk-18.0.2_x64 | 2832.787 | 1096.603 (38.71%) | 244.491 (8.63%) | 51.601 (1.82%) |
| ecs.c6r.xlarge | oracle-jdk1.8.0_341_aarch64 | 1275.118 | 737.23 (57.82%) | 192.359 (15.09%) | 36.881 (2.89%) |
| ecs.c6r.xlarge | oracle-jdk-11.0.16_aarch64 | 1665.656 | 794.867 (47.72%) | 178.034 (10.69%) | 36.896 (2.22%) |
| ecs.c6r.xlarge | oracle-jdk-17.0.4_aarch64 | 1807.769 | 811.996 (44.92%) | 207.531 (11.48%) | 38.352 (2.12%) |
| ecs.c6r.xlarge | oracle-jdk-18.0.2_aarch64 | 1738.85 | 829.281 (47.69%) | 187.111 (10.76%) | 38.478 (2.21%) |
| ecs.g8m.xlarge | oracle-jdk1.8.0_341_aarch64 | 1412.516 | 788.736 (55.84%) | 197.661 (13.99%) | 42.303 (2.99%) |
| ecs.g8m.xlarge | oracle-jdk-11.0.16_aarch64 | 2033.422 | 1012.32 (49.78%) | 198.501 (9.76%) | 39.644 (1.95%) |
| ecs.g8m.xlarge | oracle-jdk-17.0.4_aarch64 | 1237.369 | 1084.535 (87.65%) | 208.79 (16.87%) | 38.627 (3.12%) |
| ecs.g8m.xlarge | oracle-jdk-18.0.2_aarch64 | 2194.944 | 1077.308 (49.08%) | 206.82 (9.42%) | 40.76 (1.86%) |
EishayParseBinaryArrayMapping
| aliyun ecs spec | jdk version | fastjson2JSONB | kryo | fastjson2UTF8Bytes | fastjson1UTF8Bytes |
|---|---|---|---|---|---|
| ecs.c7.xlarge | oracle-jdk1.8.0_341_x64 | 2596.519 | 1670.242 (64.33%) | 1637.786 (63.08%) | 1477.441 (56.9%) |
| ecs.c7.xlarge | oracle-jdk-11.0.16_x64 | 3573.269 | 1626.663 (45.52%) | 1799.181 (50.35%) | 1500.241 (41.99%) |
| ecs.c7.xlarge | oracle-jdk-17.0.4_x64 | 4379.766 | 1517.988 (34.66%) | 1843.165 (42.08%) | 1660.621 (37.92%) |
| ecs.c7.xlarge | oracle-jdk-18.0.2_x64 | 4379.617 | 1620.602 (37%) | 2024.088 (46.22%) | 1651.915 (37.72%) |
| ecs.c7a.xlarge | oracle-jdk1.8.0_341_x64 | 2532.062 | 1677.739 (66.26%) | 1411.492 (55.74%) | 1442.849 (56.98%) |
| ecs.c7a.xlarge | oracle-jdk-11.0.16_x64 | 3680.493 | 1625.568 (44.17%) | 1728.598 (46.97%) | 1478.464 (40.17%) |
| ecs.c7a.xlarge | oracle-jdk-17.0.4_x64 | 4116.458 | 1540.019 (37.41%) | 1774.911 (43.12%) | 1511.726 (36.72%) |
| ecs.c7a.xlarge | oracle-jdk-18.0.2_x64 | 4112.949 | 1532.832 (37.27%) | 1817.012 (44.18%) | 1548.214 (37.64%) |
| ecs.c6r.xlarge | oracle-jdk1.8.0_341_aarch64 | 2144.7 | 1304.571 (60.83%) | 1076.114 (50.18%) | 956.514 (44.6%) |
| ecs.c6r.xlarge | oracle-jdk-11.0.16_aarch64 | 2513.785 | 1264.964 (50.32%) | 1136.504 (45.21%) | 1041.17 (41.42%) |
| ecs.c6r.xlarge | oracle-jdk-17.0.4_aarch64 | 2841.733 | 1232.525 (43.37%) | 1189.253 (41.85%) | 1174.023 (41.31%) |
| ecs.c6r.xlarge | oracle-jdk-18.0.2_aarch64 | 2724.325 | 1190.033 (43.68%) | 1198.371 (43.99%) | 1130.639 (41.5%) |
| ecs.g8m.xlarge | oracle-jdk1.8.0_341_aarch64 | 2380.175 | 1169.307 (49.13%) | 1121.425 (47.12%) | 1128.1 (47.4%) |
| ecs.g8m.xlarge | oracle-jdk-11.0.16_aarch64 | 3062.023 | 1413.686 (46.17%) | 1512.621 (49.4%) | 1262.167 (41.22%) |
| ecs.g8m.xlarge | oracle-jdk-17.0.4_aarch64 | 3513.267 | 1295.668 (36.88%) | 1505.257 (42.84%) | 1349.704 (38.42%) |
| ecs.g8m.xlarge | oracle-jdk-18.0.2_aarch64 | 3363.479 | 1269.632 (37.75%) | 1609.471 (47.85%) | 1387.333 (41.25%) |
EishayParseBinaryAutoType
| aliyun ecs spec | jdk version | fastjson2JSONB | hessian | javaSerialize |
|---|---|---|---|---|
| ecs.c7.xlarge | oracle-jdk1.8.0_341_x64 | 1452.7 | 275.555 (18.97%) | 47.892 (3.3%) |
| ecs.c7.xlarge | oracle-jdk-11.0.16_x64 | 1911.591 | 250.665 (13.11%) | 48.384 (2.53%) |
| ecs.c7.xlarge | oracle-jdk-17.0.4_x64 | 2220.64 | 256.768 (11.56%) | 51.903 (2.34%) |
| ecs.c7.xlarge | oracle-jdk-18.0.2_x64 | 2167.452 | 243.41 (11.23%) | 51.378 (2.37%) |
| ecs.c7a.xlarge | oracle-jdk1.8.0_341_x64 | 1515.357 | 285.838 (18.86%) | 46.537 (3.07%) |
| ecs.c7a.xlarge | oracle-jdk-11.0.16_x64 | 2036.116 | 248.279 (12.19%) | 47.465 (2.33%) |
| ecs.c7a.xlarge | oracle-jdk-17.0.4_x64 | 2189.527 | 251.01 (11.46%) | 53.865 (2.46%) |
| ecs.c7a.xlarge | oracle-jdk-18.0.2_x64 | 2057.963 | 242.597 (11.79%) | 51.31 (2.49%) |
| ecs.c6r.xlarge | oracle-jdk1.8.0_341_aarch64 | 1112.115 | 194.998 (17.53%) | 37.357 (3.36%) |
| ecs.c6r.xlarge | oracle-jdk-11.0.16_aarch64 | 1321.199 | 181.184 (13.71%) | 36.93 (2.8%) |
| ecs.c6r.xlarge | oracle-jdk-17.0.4_aarch64 | 1421.268 | 204.74 (14.41%) | 38.777 (2.73%) |
| ecs.c6r.xlarge | oracle-jdk-18.0.2_aarch64 | 1407.88 | 186.679 (13.26%) | 38.842 (2.76%) |
| ecs.g8m.xlarge | oracle-jdk1.8.0_341_aarch64 | 1166.697 | 201.365 (17.26%) | 41.942 (3.59%) |
| ecs.g8m.xlarge | oracle-jdk-11.0.16_aarch64 | 1644.599 | 205.623 (12.5%) | 38.299 (2.33%) |
| ecs.g8m.xlarge | oracle-jdk-17.0.4_aarch64 | 1688.122 | 209.175 (12.39%) | 39.136 (2.32%) |
| ecs.g8m.xlarge | oracle-jdk-18.0.2_aarch64 | 1507.786 | 185.421 (12.3%) | 41.64 (2.76%) |
EishayParseString
| aliyun ecs spec | jdk version | fastjson2 | fastjson1 | jackson | gson |
|---|---|---|---|---|---|
| ecs.c7.xlarge | oracle-jdk1.8.0_341_x64 | 1360.568 | 1011.738 (74.36%) | 526.676 (38.71%) | 432.017 (31.75%) |
| ecs.c7.xlarge | oracle-jdk-11.0.16_x64 | 1228.065 | 914.894 (74.5%) | 470.822 (38.34%) | 422.16 (34.38%) |
| ecs.c7.xlarge | oracle-jdk-17.0.4_x64 | 1364.202 | 1256.679 (92.12%) | 503.53 (36.91%) | 457.547 (33.54%) |
| ecs.c7.xlarge | oracle-jdk-18.0.2_x64 | 1370.066 | 1179.882 (86.12%) | 492.247 (35.93%) | 420.361 (30.68%) |
| ecs.c7a.xlarge | oracle-jdk1.8.0_341_x64 | 1286.529 | 1071.109 (83.26%) | 525.017 (40.81%) | 454.12 (35.3%) |
| ecs.c7a.xlarge | oracle-jdk-11.0.16_x64 | 1249.335 | 940.833 (75.31%) | 485.729 (38.88%) | 468.326 (37.49%) |
| ecs.c7a.xlarge | oracle-jdk-17.0.4_x64 | 1310.954 | 1293.647 (98.68%) | 515.493 (39.32%) | 511.211 (39%) |
| ecs.c7a.xlarge | oracle-jdk-18.0.2_x64 | 1147.499 | 1179.527 (102.79%) | 496.404 (43.26%) | 445.762 (38.85%) |
| ecs.c6r.xlarge | oracle-jdk1.8.0_341_aarch64 | 872.976 | 719.895 (82.46%) | 379.914 (43.52%) | 310.103 (35.52%) |
| ecs.c6r.xlarge | oracle-jdk-11.0.16_aarch64 | 871.471 | 736.203 (84.48%) | 377.196 (43.28%) | 318.83 (36.59%) |
| ecs.c6r.xlarge | oracle-jdk-17.0.4_aarch64 | 879.445 | 1015.535 (115.47%) | 378.534 (43.04%) | 312.391 (35.52%) |
| ecs.c6r.xlarge | oracle-jdk-18.0.2_aarch64 | 880.765 | 993.02 (112.75%) | 361.865 (41.09%) | 301.743 (34.26%) |
| ecs.g8m.xlarge | oracle-jdk1.8.0_341_aarch64 | 914.457 | 725.44 (79.33%) | 367.634 (40.2%) | 339.642 (37.14%) |
| ecs.g8m.xlarge | oracle-jdk-11.0.16_aarch64 | 1080.758 | 808.698 (74.83%) | 405.438 (37.51%) | 373.572 (34.57%) |
| ecs.g8m.xlarge | oracle-jdk-17.0.4_aarch64 | 1130.264 | 1028.981 (91.04%) | 410.39 (36.31%) | 347.428 (30.74%) |
| ecs.g8m.xlarge | oracle-jdk-18.0.2_aarch64 | 990.989 | 1136.849 (114.72%) | 403.869 (40.75%) | 362.801 (36.61%) |
EishayParseStringPretty
| aliyun ecs spec | jdk version | fastjson2 | fastjson1 | jackson | gson |
|---|---|---|---|---|---|
| ecs.c7.xlarge | oracle-jdk1.8.0_341_x64 | 989.92 | 268.764 (27.15%) | 493.855 (49.89%) | 401.828 (40.59%) |
| ecs.c7.xlarge | oracle-jdk-11.0.16_x64 | 929.77 | 241.376 (25.96%) | 483.608 (52.01%) | 415.913 (44.73%) |
| ecs.c7.xlarge | oracle-jdk-17.0.4_x64 | 987.743 | 294.252 (29.79%) | 462.903 (46.86%) | 447.734 (45.33%) |
| ecs.c7.xlarge | oracle-jdk-18.0.2_x64 | 970.0 | 284.132 (29.29%) | 452.741 (46.67%) | 395.039 (40.73%) |
| ecs.c7a.xlarge | oracle-jdk1.8.0_341_x64 | 992.633 | 282.002 (28.41%) | 480.261 (48.38%) | 411.905 (41.5%) |
| ecs.c7a.xlarge | oracle-jdk-11.0.16_x64 | 873.323 | 251.499 (28.8%) | 446.893 (51.17%) | 420.166 (48.11%) |
| ecs.c7a.xlarge | oracle-jdk-17.0.4_x64 | 891.968 | 299.75 (33.61%) | 488.85 (54.81%) | 482.449 (54.09%) |
| ecs.c7a.xlarge | oracle-jdk-18.0.2_x64 | 868.572 | 293.284 (33.77%) | 456.26 (52.53%) | 410.161 (47.22%) |
| ecs.c6r.xlarge | oracle-jdk1.8.0_341_aarch64 | 685.663 | 208.336 (30.38%) | 345.876 (50.44%) | 281.817 (41.1%) |
| ecs.c6r.xlarge | oracle-jdk-11.0.16_aarch64 | 668.422 | 212.383 (31.77%) | 344.776 (51.58%) | 295.781 (44.25%) |
| ecs.c6r.xlarge | oracle-jdk-17.0.4_aarch64 | 665.231 | 242.005 (36.38%) | 346.526 (52.09%) | 294.261 (44.23%) |
| ecs.c6r.xlarge | oracle-jdk-18.0.2_aarch64 | 673.288 | 228.153 (33.89%) | 333.383 (49.52%) | 276.64 (41.09%) |
| ecs.g8m.xlarge | oracle-jdk1.8.0_341_aarch64 | 725.106 | 212.969 (29.37%) | 339.355 (46.8%) | 314.208 (43.33%) |
| ecs.g8m.xlarge | oracle-jdk-11.0.16_aarch64 | 790.702 | 228.49 (28.9%) | 379.777 (48.03%) | 336.26 (42.53%) |
| ecs.g8m.xlarge | oracle-jdk-17.0.4_aarch64 | 814.156 | 259.078 (31.82%) | 379.597 (46.62%) | 311.307 (38.24%) |
| ecs.g8m.xlarge | oracle-jdk-18.0.2_aarch64 | 798.532 | 242.843 (30.41%) | 356.333 (44.62%) | 290.978 (36.44%) |
EishayParseTreeString
| aliyun ecs spec | jdk version | fastjson2 | fastjson1 | jackson | gson |
|---|---|---|---|---|---|
| ecs.c7.xlarge | oracle-jdk1.8.0_341_x64 | 997.653 | 515.969 (51.72%) | 495.047 (49.62%) | 339.088 (33.99%) |
| ecs.c7.xlarge | oracle-jdk-11.0.16_x64 | 835.382 | 396.672 (47.48%) | 437.821 (52.41%) | 320.745 (38.4%) |
| ecs.c7.xlarge | oracle-jdk-17.0.4_x64 | 1088.249 | 591.931 (54.39%) | 506.817 (46.57%) | 313.176 (28.78%) |
| ecs.c7.xlarge | oracle-jdk-18.0.2_x64 | 1128.092 | 563.691 (49.97%) | 456.86 (40.5%) | 321.169 (28.47%) |
| ecs.c7a.xlarge | oracle-jdk1.8.0_341_x64 | 1014.7 | 477.79 (47.09%) | 559.775 (55.17%) | 374.786 (36.94%) |
| ecs.c7a.xlarge | oracle-jdk-11.0.16_x64 | 848.016 | 423.335 (49.92%) | 466.498 (55.01%) | 375.204 (44.24%) |
| ecs.c7a.xlarge | oracle-jdk-17.0.4_x64 | 980.59 | 523.15 (53.35%) | 554.072 (56.5%) | 377.676 (38.52%) |
| ecs.c7a.xlarge | oracle-jdk-18.0.2_x64 | 1042.413 | 527.567 (50.61%) | 499.371 (47.91%) | 379.75 (36.43%) |
| ecs.c6r.xlarge | oracle-jdk1.8.0_341_aarch64 | 561.623 | 305.922 (54.47%) | 359.392 (63.99%) | 259.908 (46.28%) |
| ecs.c6r.xlarge | oracle-jdk-11.0.16_aarch64 | 546.837 | 320.225 (58.56%) | 348.703 (63.77%) | 262.577 (48.02%) |
| ecs.c6r.xlarge | oracle-jdk-17.0.4_aarch64 | 628.838 | 358.546 (57.02%) | 381.614 (60.69%) | 259.51 (41.27%) |
| ecs.c6r.xlarge | oracle-jdk-18.0.2_aarch64 | 632.975 | 339.814 (53.69%) | 364.472 (57.58%) | 260.563 (41.16%) |
| ecs.g8m.xlarge | oracle-jdk1.8.0_341_aarch64 | 565.736 | 300.699 (53.15%) | 324.266 (57.32%) | 262.866 (46.46%) |
| ecs.g8m.xlarge | oracle-jdk-11.0.16_aarch64 | 662.551 | 361.773 (54.6%) | 385.641 (58.21%) | 301.285 (45.47%) |
| ecs.g8m.xlarge | oracle-jdk-17.0.4_aarch64 | 827.05 | 395.672 (47.84%) | 424.3 (51.3%) | 298.869 (36.14%) |
| ecs.g8m.xlarge | oracle-jdk-18.0.2_aarch64 | 824.21 | 378.399 (45.91%) | 413.141 (50.13%) | 280.966 (34.09%) |
EishayParseTreeStringPretty
| aliyun ecs spec | jdk version | fastjson2 | fastjson1 | jackson | gson |
|---|---|---|---|---|---|
| ecs.c7.xlarge | oracle-jdk1.8.0_341_x64 | 741.622 | 442.451 (59.66%) | 470.821 (63.49%) | 325.071 (43.83%) |
| ecs.c7.xlarge | oracle-jdk-11.0.16_x64 | 694.684 | 345.625 (49.75%) | 426.819 (61.44%) | 304.559 (43.84%) |
| ecs.c7.xlarge | oracle-jdk-17.0.4_x64 | 790.998 | 499.636 (63.17%) | 460.409 (58.21%) | 304.138 (38.45%) |
| ecs.c7.xlarge | oracle-jdk-18.0.2_x64 | 848.877 | 479.43 (56.48%) | 429.919 (50.65%) | 304.614 (35.88%) |
| ecs.c7a.xlarge | oracle-jdk1.8.0_341_x64 | 785.342 | 442.466 (56.34%) | 504.101 (64.19%) | 347.044 (44.19%) |
| ecs.c7a.xlarge | oracle-jdk-11.0.16_x64 | 639.487 | 358.208 (56.01%) | 433.084 (67.72%) | 353.091 (55.21%) |
| ecs.c7a.xlarge | oracle-jdk-17.0.4_x64 | 780.458 | 468.714 (60.06%) | 461.578 (59.14%) | 366.71 (46.99%) |
| ecs.c7a.xlarge | oracle-jdk-18.0.2_x64 | 768.266 | 452.967 (58.96%) | 453.383 (59.01%) | 358.083 (46.61%) |
| ecs.c6r.xlarge | oracle-jdk1.8.0_341_aarch64 | 509.956 | 267.584 (52.47%) | 329.445 (64.6%) | 249.376 (48.9%) |
| ecs.c6r.xlarge | oracle-jdk-11.0.16_aarch64 | 464.579 | 273.13 (58.79%) | 328.427 (70.69%) | 245.934 (52.94%) |
| ecs.c6r.xlarge | oracle-jdk-17.0.4_aarch64 | 511.317 | 304.124 (59.48%) | 335.73 (65.66%) | 244.56 (47.83%) |
| ecs.c6r.xlarge | oracle-jdk-18.0.2_aarch64 | 512.372 | 292.182 (57.03%) | 337.127 (65.8%) | 241.461 (47.13%) |
| ecs.g8m.xlarge | oracle-jdk1.8.0_341_aarch64 | 473.673 | 273.219 (57.68%) | 297.812 (62.87%) | 252.424 (53.29%) |
| ecs.g8m.xlarge | oracle-jdk-11.0.16_aarch64 | 555.834 | 283.588 (51.02%) | 362.308 (65.18%) | 284.897 (51.26%) |
| ecs.g8m.xlarge | oracle-jdk-17.0.4_aarch64 | 636.309 | 362.532 (56.97%) | 383.031 (60.2%) | 284.047 (44.64%) |
| ecs.g8m.xlarge | oracle-jdk-18.0.2_aarch64 | 648.283 | 337.279 (52.03%) | 370.35 (57.13%) | 265.808 (41%) |
EishayParseTreeUTF8Bytes
| aliyun ecs spec | jdk version | fastjson2 | fastjson1 | jackson | gson |
|---|---|---|---|---|---|
| ecs.c7.xlarge | oracle-jdk1.8.0_341_x64 | 888.341 | 443.261 (49.9%) | 568.84 (64.03%) | 317.759 (35.77%) |
| ecs.c7.xlarge | oracle-jdk-11.0.16_x64 | 680.764 | 364.282 (53.51%) | 521.999 (76.68%) | 311.617 (45.77%) |
| ecs.c7.xlarge | oracle-jdk-17.0.4_x64 | 998.497 | 474.214 (47.49%) | 565.47 (56.63%) | 314.666 (31.51%) |
| ecs.c7.xlarge | oracle-jdk-18.0.2_x64 | 1049.43 | 472.92 (45.06%) | 571.927 (54.5%) | 317.421 (30.25%) |
| ecs.c7a.xlarge | oracle-jdk1.8.0_341_x64 | 830.222 | 447.576 (53.91%) | 588.739 (70.91%) | 338.224 (40.74%) |
| ecs.c7a.xlarge | oracle-jdk-11.0.16_x64 | 720.322 | 373.026 (51.79%) | 530.69 (73.67%) | 355.912 (49.41%) |
| ecs.c7a.xlarge | oracle-jdk-17.0.4_x64 | 926.126 | 483.934 (52.25%) | 604.38 (65.26%) | 372.952 (40.27%) |
| ecs.c7a.xlarge | oracle-jdk-18.0.2_x64 | 932.104 | 453.746 (48.68%) | 610.944 (65.54%) | 374.626 (40.19%) |
| ecs.c6r.xlarge | oracle-jdk1.8.0_341_aarch64 | 545.364 | 246.867 (45.27%) | 438.259 (80.36%) | 239.268 (43.87%) |
| ecs.c6r.xlarge | oracle-jdk-11.0.16_aarch64 | 506.61 | 285.387 (56.33%) | 414.121 (81.74%) | 253.316 (50%) |
| ecs.c6r.xlarge | oracle-jdk-17.0.4_aarch64 | 593.015 | 316.948 (53.45%) | 449.646 (75.82%) | 250.685 (42.27%) |
| ecs.c6r.xlarge | oracle-jdk-18.0.2_aarch64 | 593.565 | 297.638 (50.14%) | 439.934 (74.12%) | 252.026 (42.46%) |
| ecs.g8m.xlarge | oracle-jdk1.8.0_341_aarch64 | 500.292 | 252.389 (50.45%) | 364.197 (72.8%) | 238.913 (47.75%) |
| ecs.g8m.xlarge | oracle-jdk-11.0.16_aarch64 | 636.014 | 233.505 (36.71%) | 442.118 (69.51%) | 300.574 (47.26%) |
| ecs.g8m.xlarge | oracle-jdk-17.0.4_aarch64 | 745.396 | 360.956 (48.42%) | 508.622 (68.24%) | 284.775 (38.2%) |
| ecs.g8m.xlarge | oracle-jdk-18.0.2_aarch64 | 776.54 | 321.887 (41.45%) | 479.618 (61.76%) | 284.293 (36.61%) |
EishayParseTreeUTF8BytesPretty
| aliyun ecs spec | jdk version | fastjson2 | fastjson1 | jackson | gson |
|---|---|---|---|---|---|
| ecs.c7.xlarge | oracle-jdk1.8.0_341_x64 | 689.333 | 388.196 (56.31%) | 501.778 (72.79%) | 299.119 (43.39%) |
| ecs.c7.xlarge | oracle-jdk-11.0.16_x64 | 630.594 | 318.809 (50.56%) | 464.703 (73.69%) | 297.936 (47.25%) |
| ecs.c7.xlarge | oracle-jdk-17.0.4_x64 | 809.623 | 411.36 (50.81%) | 521.423 (64.4%) | 307.098 (37.93%) |
| ecs.c7.xlarge | oracle-jdk-18.0.2_x64 | 806.045 | 393.221 (48.78%) | 518.417 (64.32%) | 292.226 (36.25%) |
| ecs.c7a.xlarge | oracle-jdk1.8.0_341_x64 | 707.563 | 376.198 (53.17%) | 521.949 (73.77%) | 309.725 (43.77%) |
| ecs.c7a.xlarge | oracle-jdk-11.0.16_x64 | 612.02 | 311.812 (50.95%) | 479.022 (78.27%) | 346.873 (56.68%) |
| ecs.c7a.xlarge | oracle-jdk-17.0.4_x64 | 747.404 | 371.091 (49.65%) | 534.919 (71.57%) | 355.101 (47.51%) |
| ecs.c7a.xlarge | oracle-jdk-18.0.2_x64 | 744.937 | 390.151 (52.37%) | 519.453 (69.73%) | 337.412 (45.29%) |
| ecs.c6r.xlarge | oracle-jdk1.8.0_341_aarch64 | 476.852 | 221.684 (46.49%) | 405.684 (85.08%) | 221.433 (46.44%) |
| ecs.c6r.xlarge | oracle-jdk-11.0.16_aarch64 | 437.704 | 243.769 (55.69%) | 379.002 (86.59%) | 240.826 (55.02%) |
| ecs.c6r.xlarge | oracle-jdk-17.0.4_aarch64 | 496.349 | 268.505 (54.1%) | 410.928 (82.79%) | 239.642 (48.28%) |
| ecs.c6r.xlarge | oracle-jdk-18.0.2_aarch64 | 497.208 | 263.357 (52.97%) | 374.934 (75.41%) | 233.462 (46.95%) |
| ecs.g8m.xlarge | oracle-jdk1.8.0_341_aarch64 | 445.331 | 233.073 (52.34%) | 329.393 (73.97%) | 222.209 (49.9%) |
| ecs.g8m.xlarge | oracle-jdk-11.0.16_aarch64 | 523.367 | 250.823 (47.92%) | 415.635 (79.42%) | 278.87 (53.28%) |
| ecs.g8m.xlarge | oracle-jdk-17.0.4_aarch64 | 613.922 | 230.916 (37.61%) | 448.64 (73.08%) | 276.341 (45.01%) |
| ecs.g8m.xlarge | oracle-jdk-18.0.2_aarch64 | 620.58 | 288.993 (46.57%) | 432.632 (69.71%) | 275.088 (44.33%) |
EishayParseUTF8Bytes
| aliyun ecs spec | jdk version | fastjson2 | fastjson1 | jackson | gson |
|---|---|---|---|---|---|
| ecs.c7.xlarge | oracle-jdk1.8.0_341_x64 | 1111.437 | 791.627 (71.23%) | 597.483 (53.76%) | 314.588 (28.3%) |
| ecs.c7.xlarge | oracle-jdk-11.0.16_x64 | 1067.251 | 734.136 (68.79%) | 565.209 (52.96%) | 315.374 (29.55%) |
| ecs.c7.xlarge | oracle-jdk-17.0.4_x64 | 1144.942 | 961.116 (83.94%) | 568.964 (49.69%) | 319.794 (27.93%) |
| ecs.c7.xlarge | oracle-jdk-18.0.2_x64 | 1200.863 | 909.789 (75.76%) | 551.602 (45.93%) | 319.82 (26.63%) |
| ecs.c7a.xlarge | oracle-jdk1.8.0_341_x64 | 1048.072 | 835.454 (79.71%) | 616.641 (58.84%) | 335.258 (31.99%) |
| ecs.c7a.xlarge | oracle-jdk-11.0.16_x64 | 1056.933 | 715.322 (67.68%) | 584.955 (55.34%) | 369.708 (34.98%) |
| ecs.c7a.xlarge | oracle-jdk-17.0.4_x64 | 1043.35 | 934.783 (89.59%) | 593.304 (56.87%) | 382.881 (36.7%) |
| ecs.c7a.xlarge | oracle-jdk-18.0.2_x64 | 1067.695 | 890.046 (83.36%) | 583.981 (54.7%) | 354.728 (33.22%) |
| ecs.c6r.xlarge | oracle-jdk1.8.0_341_aarch64 | 734.367 | 564.344 (76.85%) | 454.68 (61.91%) | 239.708 (32.64%) |
| ecs.c6r.xlarge | oracle-jdk-11.0.16_aarch64 | 756.743 | 590.756 (78.07%) | 432.663 (57.17%) | 253.007 (33.43%) |
| ecs.c6r.xlarge | oracle-jdk-17.0.4_aarch64 | 784.689 | 753.819 (96.07%) | 433.961 (55.3%) | 253.17 (32.26%) |
| ecs.c6r.xlarge | oracle-jdk-18.0.2_aarch64 | 793.883 | 744.137 (93.73%) | 409.848 (51.63%) | 251.777 (31.71%) |
| ecs.g8m.xlarge | oracle-jdk1.8.0_341_aarch64 | 776.369 | 651.404 (83.9%) | 400.951 (51.64%) | 240.136 (30.93%) |
| ecs.g8m.xlarge | oracle-jdk-11.0.16_aarch64 | 981.758 | 677.353 (68.99%) | 470.72 (47.95%) | 294.994 (30.05%) |
| ecs.g8m.xlarge | oracle-jdk-17.0.4_aarch64 | 1022.609 | 604.3 (59.09%) | 387.7 (37.91%) | 280.935 (27.47%) |
| ecs.g8m.xlarge | oracle-jdk-18.0.2_aarch64 | 1037.552 | 718.338 (69.23%) | 440.787 (42.48%) | 280.512 (27.04%) |
EishayParseUTF8BytesPretty
| aliyun ecs spec | jdk version | fastjson2 | fastjson1 | jackson | gson |
|---|---|---|---|---|---|
| ecs.c7.xlarge | oracle-jdk1.8.0_341_x64 | 855.147 | 244.254 (28.56%) | 534.756 (62.53%) | 295.954 (34.61%) |
| ecs.c7.xlarge | oracle-jdk-11.0.16_x64 | 872.863 | 228.512 (26.18%) | 504.883 (57.84%) | 303.156 (34.73%) |
| ecs.c7.xlarge | oracle-jdk-17.0.4_x64 | 922.879 | 271.345 (29.4%) | 515.074 (55.81%) | 300.399 (32.55%) |
| ecs.c7.xlarge | oracle-jdk-18.0.2_x64 | 923.358 | 259.192 (28.07%) | 501.348 (54.3%) | 303.876 (32.91%) |
| ecs.c7a.xlarge | oracle-jdk1.8.0_341_x64 | 821.208 | 250.663 (30.52%) | 531.638 (64.74%) | 310.949 (37.86%) |
| ecs.c7a.xlarge | oracle-jdk-11.0.16_x64 | 828.301 | 226.97 (27.4%) | 510.674 (61.65%) | 347.851 (42%) |
| ecs.c7a.xlarge | oracle-jdk-17.0.4_x64 | 844.497 | 272.893 (32.31%) | 550.077 (65.14%) | 349.511 (41.39%) |
| ecs.c7a.xlarge | oracle-jdk-18.0.2_x64 | 842.092 | 246.454 (29.27%) | 505.556 (60.04%) | 357.569 (42.46%) |
| ecs.c6r.xlarge | oracle-jdk1.8.0_341_aarch64 | 611.652 | 191.031 (31.23%) | 413.802 (67.65%) | 221.758 (36.26%) |
| ecs.c6r.xlarge | oracle-jdk-11.0.16_aarch64 | 595.929 | 194.513 (32.64%) | 393.261 (65.99%) | 240.663 (40.38%) |
| ecs.c6r.xlarge | oracle-jdk-17.0.4_aarch64 | 614.816 | 213.522 (34.73%) | 391.126 (63.62%) | 239.461 (38.95%) |
| ecs.c6r.xlarge | oracle-jdk-18.0.2_aarch64 | 620.684 | 204.447 (32.94%) | 373.276 (60.14%) | 233.597 (37.64%) |
| ecs.g8m.xlarge | oracle-jdk1.8.0_341_aarch64 | 657.892 | 202.629 (30.8%) | 379.336 (57.66%) | 226.383 (34.41%) |
| ecs.g8m.xlarge | oracle-jdk-11.0.16_aarch64 | 738.666 | 154.865 (20.97%) | 425.271 (57.57%) | 253.703 (34.35%) |
| ecs.g8m.xlarge | oracle-jdk-17.0.4_aarch64 | 754.557 | 232.948 (30.87%) | 387.308 (51.33%) | 279.334 (37.02%) |
| ecs.g8m.xlarge | oracle-jdk-18.0.2_aarch64 | 785.998 | 217.533 (27.68%) | 408.091 (51.92%) | 271.914 (34.59%) |
EishayWriteBinary
| aliyun ecs spec | jdk version | fastjson2JSONB | fastjson2UTF8Bytes | hessian | javaSerialize |
|---|---|---|---|---|---|
| ecs.c7.xlarge | oracle-jdk1.8.0_341_x64 | 2097.46 | 1491.388 (71.1%) | 344.249 (16.41%) | 234.23 (11.17%) |
| ecs.c7.xlarge | oracle-jdk-11.0.16_x64 | 2436.506 | 1562.927 (64.15%) | 330.66 (13.57%) | 209.629 (8.6%) |
| ecs.c7.xlarge | oracle-jdk-17.0.4_x64 | 3309.755 | 1845.598 (55.76%) | 321.034 (9.7%) | 221.56 (6.69%) |
| ecs.c7.xlarge | oracle-jdk-18.0.2_x64 | 3227.077 | 1828.192 (56.65%) | 324.449 (10.05%) | 231.471 (7.17%) |
| ecs.c7a.xlarge | oracle-jdk1.8.0_341_x64 | 2054.803 | 1504.894 (73.24%) | 366.379 (17.83%) | 239.777 (11.67%) |
| ecs.c7a.xlarge | oracle-jdk-11.0.16_x64 | 2705.693 | 1764.638 (65.22%) | 357.997 (13.23%) | 229.602 (8.49%) |
| ecs.c7a.xlarge | oracle-jdk-17.0.4_x64 | 2865.521 | 1596.312 (55.71%) | 353.936 (12.35%) | 249.249 (8.7%) |
| ecs.c7a.xlarge | oracle-jdk-18.0.2_x64 | 2771.114 | 1749.079 (63.12%) | 357.223 (12.89%) | 265.558 (9.58%) |
| ecs.c6r.xlarge | oracle-jdk1.8.0_341_aarch64 | 1348.365 | 1103.207 (81.82%) | 289.951 (21.5%) | 181.14 (13.43%) |
| ecs.c6r.xlarge | oracle-jdk-11.0.16_aarch64 | 1842.171 | 1145.927 (62.21%) | 318.719 (17.3%) | 185.214 (10.05%) |
| ecs.c6r.xlarge | oracle-jdk-17.0.4_aarch64 | 1821.557 | 1155.853 (63.45%) | 310.023 (17.02%) | 179.866 (9.87%) |
| ecs.c6r.xlarge | oracle-jdk-18.0.2_aarch64 | 1821.794 | 1159.775 (63.66%) | 305.48 (16.77%) | 192.008 (10.54%) |
| ecs.g8m.xlarge | oracle-jdk1.8.0_341_aarch64 | 1563.48 | 1300.107 (83.15%) | 344.569 (22.04%) | 206.703 (13.22%) |
| ecs.g8m.xlarge | oracle-jdk-11.0.16_aarch64 | 2221.289 | 1323.907 (59.6%) | 330.132 (14.86%) | 217.229 (9.78%) |
| ecs.g8m.xlarge | oracle-jdk-17.0.4_aarch64 | 2241.298 | 1309.735 (58.44%) | 327.589 (14.62%) | 209.455 (9.35%) |
| ecs.g8m.xlarge | oracle-jdk-18.0.2_aarch64 | 2378.319 | 1427.898 (60.04%) | 337.284 (14.18%) | 225.171 (9.47%) |
EishayWriteBinaryArrayMapping
| aliyun ecs spec | jdk version | fastjson2JSONB | kryo | fastjson2UTF8Bytes | fastjson1UTF8Bytes |
|---|---|---|---|---|---|
| ecs.c7.xlarge | oracle-jdk1.8.0_341_x64 | 3483.583 | 1850.57 (53.12%) | 1874.434 (53.81%) | 742.27 (21.31%) |
| ecs.c7.xlarge | oracle-jdk-11.0.16_x64 | 4823.255 | 1948.251 (40.39%) | 2052.985 (42.56%) | 687.918 (14.26%) |
| ecs.c7.xlarge | oracle-jdk-17.0.4_x64 | 5515.745 | 1857.421 (33.67%) | 2134.039 (38.69%) | 700.7 (12.7%) |
| ecs.c7.xlarge | oracle-jdk-18.0.2_x64 | 5433.671 | 1772.111 (32.61%) | 2107.956 (38.79%) | 675.791 (12.44%) |
| ecs.c7a.xlarge | oracle-jdk1.8.0_341_x64 | 3368.634 | 1809.89 (53.73%) | 1923.277 (57.09%) | 703.748 (20.89%) |
| ecs.c7a.xlarge | oracle-jdk-11.0.16_x64 | 4993.751 | 1981.804 (39.69%) | 2132.327 (42.7%) | 670.554 (13.43%) |
| ecs.c7a.xlarge | oracle-jdk-17.0.4_x64 | 5413.076 | 1940.991 (35.86%) | 1929.967 (35.65%) | 695.953 (12.86%) |
| ecs.c7a.xlarge | oracle-jdk-18.0.2_x64 | 5461.737 | 1710.222 (31.31%) | 2109.615 (38.63%) | 665.313 (12.18%) |
| ecs.c6r.xlarge | oracle-jdk1.8.0_341_aarch64 | 1889.099 | 1100.995 (58.28%) | 1305.386 (69.1%) | 417.284 (22.09%) |
| ecs.c6r.xlarge | oracle-jdk-11.0.16_aarch64 | 3348.054 | 1312.34 (39.2%) | 1353.977 (40.44%) | 424.222 (12.67%) |
| ecs.c6r.xlarge | oracle-jdk-17.0.4_aarch64 | 3264.98 | 1234.06 (37.8%) | 1346.775 (41.25%) | 454.362 (13.92%) |
| ecs.c6r.xlarge | oracle-jdk-18.0.2_aarch64 | 3324.861 | 1288.712 (38.76%) | 1328.958 (39.97%) | 419.581 (12.62%) |
| ecs.g8m.xlarge | oracle-jdk1.8.0_341_aarch64 | 2316.912 | 1419.395 (61.26%) | 1511.067 (65.22%) | 475.813 (20.54%) |
| ecs.g8m.xlarge | oracle-jdk-11.0.16_aarch64 | 4023.978 | 1537.446 (38.21%) | 1649.468 (40.99%) | 465.259 (11.56%) |
| ecs.g8m.xlarge | oracle-jdk-17.0.4_aarch64 | 4139.308 | 1402.678 (33.89%) | 1673.291 (40.42%) | 549.793 (13.28%) |
| ecs.g8m.xlarge | oracle-jdk-18.0.2_aarch64 | 3594.195 | 1436.316 (39.96%) | 1673.964 (46.57%) | 438.79 (12.21%) |
EishayWriteBinaryAutoType
| aliyun ecs spec | jdk version | fastjson2JSONB | fastjson2UTF8Bytes | hessian | javaSerialize |
|---|---|---|---|---|---|
| ecs.c7.xlarge | oracle-jdk1.8.0_341_x64 | 1182.789 | 1428.676 (120.79%) | 341.582 (28.88%) | 229.365 (19.39%) |
| ecs.c7.xlarge | oracle-jdk-11.0.16_x64 | 1183.059 | 1526.07 (128.99%) | 332.916 (28.14%) | 205.847 (17.4%) |
| ecs.c7.xlarge | oracle-jdk-17.0.4_x64 | 1436.222 | 1772.479 (123.41%) | 320.823 (22.34%) | 221.056 (15.39%) |
| ecs.c7.xlarge | oracle-jdk-18.0.2_x64 | 1418.529 | 1779.766 (125.47%) | 323.363 (22.8%) | 246.546 (17.38%) |
| ecs.c7a.xlarge | oracle-jdk1.8.0_341_x64 | 1212.582 | 1400.881 (115.53%) | 357.797 (29.51%) | 235.548 (19.43%) |
| ecs.c7a.xlarge | oracle-jdk-11.0.16_x64 | 1377.015 | 1685.36 (122.39%) | 355.538 (25.82%) | 242.805 (17.63%) |
| ecs.c7a.xlarge | oracle-jdk-17.0.4_x64 | 1502.099 | 1710.344 (113.86%) | 352.902 (23.49%) | 248.36 (16.53%) |
| ecs.c7a.xlarge | oracle-jdk-18.0.2_x64 | 1491.452 | 1618.4 (108.51%) | 352.32 (23.62%) | 255.885 (17.16%) |
| ecs.c6r.xlarge | oracle-jdk1.8.0_341_aarch64 | 853.949 | 1077.438 (126.17%) | 297.927 (34.89%) | 180.202 (21.1%) |
| ecs.c6r.xlarge | oracle-jdk-11.0.16_aarch64 | 939.645 | 1123.858 (119.6%) | 319.326 (33.98%) | 189.815 (20.2%) |
| ecs.c6r.xlarge | oracle-jdk-17.0.4_aarch64 | 968.269 | 1109.001 (114.53%) | 309.125 (31.93%) | 180.915 (18.68%) |
| ecs.c6r.xlarge | oracle-jdk-18.0.2_aarch64 | 954.092 | 1105.004 (115.82%) | 307.621 (32.24%) | 191.208 (20.04%) |
| ecs.g8m.xlarge | oracle-jdk1.8.0_341_aarch64 | 953.974 | 1237.636 (129.73%) | 341.802 (35.83%) | 205.166 (21.51%) |
| ecs.g8m.xlarge | oracle-jdk-11.0.16_aarch64 | 1145.914 | 1278.021 (111.53%) | 337.779 (29.48%) | 214.354 (18.71%) |
| ecs.g8m.xlarge | oracle-jdk-17.0.4_aarch64 | 888.078 | 1289.528 (145.2%) | 326.178 (36.73%) | 209.768 (23.62%) |
| ecs.g8m.xlarge | oracle-jdk-18.0.2_aarch64 | 999.438 | 1368.184 (136.9%) | 333.029 (33.32%) | 224.949 (22.51%) |
EishayWriteString
| aliyun ecs spec | jdk version | fastjson2 | fastjson1 | jackson | gson |
|---|---|---|---|---|---|
| ecs.c7.xlarge | oracle-jdk1.8.0_341_x64 | 1576.265 | 619.203 (39.28%) | 943.772 (59.87%) | 322.901 (20.49%) |
| ecs.c7.xlarge | oracle-jdk-11.0.16_x64 | 1335.098 | 587.182 (43.98%) | 933.029 (69.88%) | 275.623 (20.64%) |
| ecs.c7.xlarge | oracle-jdk-17.0.4_x64 | 1678.255 | 618.906 (36.88%) | 1034.137 (61.62%) | 201.428 (12%) |
| ecs.c7.xlarge | oracle-jdk-18.0.2_x64 | 1644.231 | 593.6 (36.1%) | 908.705 (55.27%) | 203.305 (12.36%) |
| ecs.c7a.xlarge | oracle-jdk1.8.0_341_x64 | 1618.597 | 643.347 (39.75%) | 899.484 (55.57%) | 376.278 (23.25%) |
| ecs.c7a.xlarge | oracle-jdk-11.0.16_x64 | 1440.586 | 609.974 (42.34%) | 950.891 (66.01%) | 264.998 (18.4%) |
| ecs.c7a.xlarge | oracle-jdk-17.0.4_x64 | 1741.048 | 640.155 (36.77%) | 970.425 (55.74%) | 337.577 (19.39%) |
| ecs.c7a.xlarge | oracle-jdk-18.0.2_x64 | 1662.442 | 613.616 (36.91%) | 853.506 (51.34%) | 318.316 (19.15%) |
| ecs.c6r.xlarge | oracle-jdk1.8.0_341_aarch64 | 1044.235 | 458.396 (43.9%) | 571.229 (54.7%) | 274.327 (26.27%) |
| ecs.c6r.xlarge | oracle-jdk-11.0.16_aarch64 | 1047.284 | 427.03 (40.77%) | 595.907 (56.9%) | 251.026 (23.97%) |
| ecs.c6r.xlarge | oracle-jdk-17.0.4_aarch64 | 1172.453 | 443.202 (37.8%) | 640.451 (54.62%) | 189.277 (16.14%) |
| ecs.c6r.xlarge | oracle-jdk-18.0.2_aarch64 | 1125.986 | 442.262 (39.28%) | 584.856 (51.94%) | 189.781 (16.85%) |
| ecs.g8m.xlarge | oracle-jdk1.8.0_341_aarch64 | 1207.801 | 488.777 (40.47%) | 629.315 (52.1%) | 330.416 (27.36%) |
| ecs.g8m.xlarge | oracle-jdk-11.0.16_aarch64 | 1172.745 | 472.56 (40.3%) | 674.348 (57.5%) | 288.784 (24.62%) |
| ecs.g8m.xlarge | oracle-jdk-17.0.4_aarch64 | 1347.999 | 500.066 (37.1%) | 605.068 (44.89%) | 194.878 (14.46%) |
| ecs.g8m.xlarge | oracle-jdk-18.0.2_aarch64 | 1314.211 | 448.914 (34.16%) | 630.25 (47.96%) | 208.63 (15.87%) |
EishayWriteUTF8Bytes
| aliyun ecs spec | jdk version | fastjson2 | fastjson1 | jackson | gson |
|---|---|---|---|---|---|
| ecs.c7.xlarge | oracle-jdk1.8.0_341_x64 | 1483.805 | 566.016 (38.15%) | 909.579 (61.3%) | 296.378 (19.97%) |
| ecs.c7.xlarge | oracle-jdk-11.0.16_x64 | 1607.916 | 535.732 (33.32%) | 840.722 (52.29%) | 277.027 (17.23%) |
| ecs.c7.xlarge | oracle-jdk-17.0.4_x64 | 1870.324 | 573.164 (30.65%) | 969.668 (51.84%) | 202.284 (10.82%) |
| ecs.c7.xlarge | oracle-jdk-18.0.2_x64 | 1842.545 | 539.979 (29.31%) | 922.569 (50.07%) | 203.819 (11.06%) |
| ecs.c7a.xlarge | oracle-jdk1.8.0_341_x64 | 1513.863 | 577.225 (38.13%) | 829.233 (54.78%) | 335.696 (22.17%) |
| ecs.c7a.xlarge | oracle-jdk-11.0.16_x64 | 1787.631 | 553.471 (30.96%) | 869.786 (48.66%) | 252.633 (14.13%) |
| ecs.c7a.xlarge | oracle-jdk-17.0.4_x64 | 1703.089 | 563.399 (33.08%) | 866.295 (50.87%) | 326.269 (19.16%) |
| ecs.c7a.xlarge | oracle-jdk-18.0.2_x64 | 1723.847 | 535.227 (31.05%) | 853.692 (49.52%) | 307.143 (17.82%) |
| ecs.c6r.xlarge | oracle-jdk1.8.0_341_aarch64 | 1114.874 | 418.141 (37.51%) | 568.404 (50.98%) | 235.234 (21.1%) |
| ecs.c6r.xlarge | oracle-jdk-11.0.16_aarch64 | 1155.121 | 384.802 (33.31%) | 553.0 (47.87%) | 249.932 (21.64%) |
| ecs.c6r.xlarge | oracle-jdk-17.0.4_aarch64 | 1155.038 | 386.631 (33.47%) | 610.788 (52.88%) | 185.482 (16.06%) |
| ecs.c6r.xlarge | oracle-jdk-18.0.2_aarch64 | 1157.346 | 348.347 (30.1%) | 588.702 (50.87%) | 185.548 (16.03%) |
| ecs.g8m.xlarge | oracle-jdk1.8.0_341_aarch64 | 1322.099 | 434.992 (32.9%) | 644.337 (48.74%) | 284.382 (21.51%) |
| ecs.g8m.xlarge | oracle-jdk-11.0.16_aarch64 | 1362.002 | 424.507 (31.17%) | 538.537 (39.54%) | 271.529 (19.94%) |
| ecs.g8m.xlarge | oracle-jdk-17.0.4_aarch64 | 1357.4 | 471.138 (34.71%) | 676.224 (49.82%) | 202.618 (14.93%) |
| ecs.g8m.xlarge | oracle-jdk-18.0.2_aarch64 | 1421.632 | 409.363 (28.8%) | 630.841 (44.37%) | 202.765 (14.26%) |
Benchmark Benchmark 2.0.13 01 (`docs/benchmark/benchmark_2.0.13_01.md`)
EishayParseBinary
| fastjson2JSONB | fastjson2JSONBArrayMapping | fastjson2UTF8Bytes | hessian | javaSerialize | kryo | |
|---|---|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 1776.198 | 2469.821 (139.05%) | 1085.531 (61.12%) | 275.831 (15.53%) | 46.697 (2.63%) | 1731.017 (97.46%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 2414.665 | 3691.598 (152.88%) | 1170.538 (48.48%) | 247.825 (10.26%) | 48.547 (2.01%) | 1602.569 (66.37%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 2378.227 | 3597.73 (151.28%) | 1171.691 (49.27%) | 255.362 (10.74%) | 53.473 (2.25%) | 1543.971 (64.92%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 2395.527 | 3697.617 (154.36%) | 1143.715 (47.74%) | 244.377 (10.2%) | 51.538 (2.15%) | 1589.784 (66.36%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 1350.569 | 1746.736 (129.33%) | 916.648 (67.87%) | 257.124 (19.04%) | 44.539 (3.3%) | 1608.242 (119.08%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 2099.249 | 3301.763 (157.28%) | 1114.014 (53.07%) | 248.134 (11.82%) | 47.128 (2.24%) | 1542.063 (73.46%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 2278.647 | 3539.067 (155.31%) | 1077.356 (47.28%) | 247.252 (10.85%) | 54.343 (2.38%) | 1611.398 (70.72%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 2317.783 | 3582.733 (154.58%) | 1141.618 (49.25%) | 243.084 (10.49%) | 51.286 (2.21%) | 1558.744 (67.25%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 1414.275 | 2109.398 (149.15%) | 754.781 (53.37%) | 191.995 (13.58%) | 37.043 (2.62%) | 1296.917 (91.7%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 1622.465 | 2529.245 (155.89%) | 774.516 (47.74%) | 179.682 (11.07%) | 36.131 (2.23%) | 1244.477 (76.7%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 1498.469 | 2175.339 (145.17%) | 792.521 (52.89%) | 208.345 (13.9%) | 39.004 (2.6%) | 1240.209 (82.77%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 1463.639 | 2166.063 (147.99%) | 749.578 (51.21%) | 187.694 (12.82%) | 39.825 (2.72%) | 1183.699 (80.87%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 1334.829 | 2245.314 (168.21%) | 795.736 (59.61%) | 195.841 (14.67%) | 41.273 (3.09%) | 1198.191 (89.76%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 1978.994 | 3084.473 (155.86%) | 1006.813 (50.87%) | 194.012 (9.8%) | 39.276 (1.98%) | 1405.982 (71.05%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 1797.283 | 2700.864 (150.27%) | 1041.756 (57.96%) | 191.073 (10.63%) | 37.238 (2.07%) | 1305.679 (72.65%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 1715.68 | 2729.703 (159.1%) | 1018.503 (59.36%) | 201.185 (11.73%) | 41.898 (2.44%) | 1328.011 (77.4%) |
EishayParseString
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 1183.105 | 1003.306 (84.8%) | 545.939 (46.14%) | 433.846 (36.67%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 1149.5 | 910.289 (79.19%) | 495.516 (43.11%) | 428.394 (37.27%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 1261.125 | 1249.568 (99.08%) | 525.814 (41.69%) | 465.156 (36.88%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1349.559 | 1188.778 (88.09%) | 509.084 (37.72%) | 413.887 (30.67%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 1168.585 | 996.665 (85.29%) | 526.359 (45.04%) | 443.691 (37.97%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 1118.289 | 933.075 (83.44%) | 485.037 (43.37%) | 455.031 (40.69%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 1214.929 | 1261.555 (103.84%) | 520.155 (42.81%) | 519.877 (42.79%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 1167.256 | 1182.899 (101.34%) | 500.029 (42.84%) | 458.703 (39.3%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 858.783 | 718.651 (83.68%) | 382.6 (44.55%) | 313.534 (36.51%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 839.238 | 736.0 (87.7%) | 375.882 (44.79%) | 318.961 (38.01%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 860.71 | 1020.396 (118.55%) | 379.63 (44.11%) | 317.062 (36.84%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 855.978 | 1005.996 (117.53%) | 364.136 (42.54%) | 300.341 (35.09%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 900.856 | 729.17 (80.94%) | 363.97 (40.4%) | 351.796 (39.05%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 1049.728 | 711.445 (67.77%) | 400.514 (38.15%) | 370.144 (35.26%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 1088.08 | 1039.371 (95.52%) | 431.543 (39.66%) | 246.416 (22.65%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 1008.766 | 1117.56 (110.78%) | 401.268 (39.78%) | 290.831 (28.83%) |
EishayParseStringPretty
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 914.558 | 274.153 (29.98%) | 472.115 (51.62%) | 405.218 (44.31%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 874.664 | 238.254 (27.24%) | 441.544 (50.48%) | 390.638 (44.66%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 952.822 | 298.537 (31.33%) | 458.117 (48.08%) | 420.953 (44.18%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 959.693 | 296.454 (30.89%) | 457.569 (47.68%) | 393.651 (41.02%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 925.279 | 275.331 (29.76%) | 465.854 (50.35%) | 428.095 (46.27%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 813.707 | 254.373 (31.26%) | 474.041 (58.26%) | 408.483 (50.2%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 855.641 | 299.122 (34.96%) | 462.087 (54%) | 502.264 (58.7%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 851.823 | 289.915 (34.03%) | 471.65 (55.37%) | 421.822 (49.52%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 680.368 | 202.58 (29.78%) | 349.934 (51.43%) | 283.049 (41.6%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 661.039 | 209.251 (31.65%) | 347.143 (52.51%) | 296.049 (44.79%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 667.244 | 241.124 (36.14%) | 353.213 (52.94%) | 294.191 (44.09%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 665.602 | 229.95 (34.55%) | 334.797 (50.3%) | 277.339 (41.67%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 707.702 | 215.408 (30.44%) | 341.281 (48.22%) | 315.418 (44.57%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 772.59 | 231.195 (29.92%) | 370.09 (47.9%) | 348.464 (45.1%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 797.914 | 261.211 (32.74%) | 375.321 (47.04%) | 313.596 (39.3%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 778.81 | 220.887 (28.36%) | 362.571 (46.55%) | 310.659 (39.89%) |
EishayParseTreeString
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 978.314 | 514.557 (52.6%) | 498.345 (50.94%) | 342.704 (35.03%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 752.449 | 399.832 (53.14%) | 451.293 (59.98%) | 319.655 (42.48%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 1011.257 | 560.203 (55.4%) | 518.779 (51.3%) | 317.092 (31.36%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1099.513 | 568.841 (51.74%) | 499.268 (45.41%) | 314.776 (28.63%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 874.023 | 466.785 (53.41%) | 493.163 (56.42%) | 362.656 (41.49%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 784.169 | 411.17 (52.43%) | 476.98 (60.83%) | 357.6 (45.6%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 1005.215 | 546.527 (54.37%) | 543.438 (54.06%) | 397.659 (39.56%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 955.849 | 537.329 (56.21%) | 550.961 (57.64%) | 399.346 (41.78%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 577.95 | 305.529 (52.86%) | 355.71 (61.55%) | 263.94 (45.67%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 535.385 | 322.454 (60.23%) | 355.045 (66.32%) | 262.062 (48.95%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 609.979 | 357.494 (58.61%) | 372.851 (61.13%) | 260.307 (42.67%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 609.34 | 336.062 (55.15%) | 353.739 (58.05%) | 255.965 (42.01%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 554.222 | 303.362 (54.74%) | 322.656 (58.22%) | 269.968 (48.71%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 651.015 | 363.95 (55.91%) | 372.883 (57.28%) | 302.107 (46.41%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 773.819 | 409.399 (52.91%) | 417.763 (53.99%) | 297.349 (38.43%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 775.688 | 355.791 (45.87%) | 403.36 (52%) | 278.74 (35.93%) |
EishayParseTreeStringPretty
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 755.992 | 436.612 (57.75%) | 471.194 (62.33%) | 322.7 (42.69%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 642.999 | 348.9 (54.26%) | 419.55 (65.25%) | 313.827 (48.81%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 790.975 | 476.483 (60.24%) | 466.528 (58.98%) | 298.663 (37.76%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 818.822 | 487.138 (59.49%) | 456.264 (55.72%) | 308.143 (37.63%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 723.133 | 419.792 (58.05%) | 477.767 (66.07%) | 346.98 (47.98%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 648.173 | 356.161 (54.95%) | 448.156 (69.14%) | 345.753 (53.34%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 763.593 | 452.14 (59.21%) | 454.43 (59.51%) | 372.215 (48.75%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 770.693 | 455.89 (59.15%) | 471.872 (61.23%) | 343.977 (44.63%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 494.933 | 268.26 (54.2%) | 327.745 (66.22%) | 243.928 (49.29%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 455.863 | 274.343 (60.18%) | 324.641 (71.21%) | 247.789 (54.36%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 502.65 | 304.495 (60.58%) | 353.314 (70.29%) | 243.809 (48.5%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 500.186 | 295.944 (59.17%) | 344.346 (68.84%) | 242.141 (48.41%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 462.261 | 280.875 (60.76%) | 305.279 (66.04%) | 262.629 (56.81%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 541.328 | 288.058 (53.21%) | 355.015 (65.58%) | 277.614 (51.28%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 620.514 | 340.342 (54.85%) | 380.709 (61.35%) | 268.22 (43.23%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 620.053 | 309.872 (49.98%) | 373.109 (60.17%) | 256.283 (41.33%) |
EishayParseTreeUTF8Bytes
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 873.771 | 431.609 (49.4%) | 578.79 (66.24%) | 315.776 (36.14%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 717.616 | 362.449 (50.51%) | 498.538 (69.47%) | 306.489 (42.71%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 1037.951 | 482.261 (46.46%) | 570.986 (55.01%) | 312.932 (30.15%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1031.888 | 478.799 (46.4%) | 559.496 (54.22%) | 315.597 (30.58%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 713.673 | 422.095 (59.14%) | 578.6 (81.07%) | 330.712 (46.34%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 707.181 | 360.429 (50.97%) | 542.8 (76.76%) | 358.739 (50.73%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 760.336 | 475.406 (62.53%) | 621.974 (81.8%) | 378.997 (49.85%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 932.351 | 438.713 (47.05%) | 587.021 (62.96%) | 382.004 (40.97%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 527.795 | 245.47 (46.51%) | 429.298 (81.34%) | 237.51 (45%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 444.899 | 285.277 (64.12%) | 429.4 (96.52%) | 253.962 (57.08%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 588.732 | 317.285 (53.89%) | 433.643 (73.66%) | 253.518 (43.06%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 557.19 | 296.458 (53.21%) | 427.762 (76.77%) | 252.048 (45.24%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 501.129 | 250.671 (50.02%) | 366.671 (73.17%) | 234.614 (46.82%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 535.255 | 301.91 (56.4%) | 444.528 (83.05%) | 295.506 (55.21%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 764.599 | 315.043 (41.2%) | 499.669 (65.35%) | 291.577 (38.13%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 704.339 | 318.756 (45.26%) | 488.969 (69.42%) | 278.16 (39.49%) |
EishayParseTreeUTF8BytesPretty
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 725.068 | 380.139 (52.43%) | 491.594 (67.8%) | 293.772 (40.52%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 594.046 | 307.351 (51.74%) | 489.479 (82.4%) | 297.61 (50.1%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 863.881 | 409.93 (47.45%) | 514.403 (59.55%) | 302.815 (35.05%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 818.23 | 405.283 (49.53%) | 515.852 (63.04%) | 295.615 (36.13%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 633.046 | 360.021 (56.87%) | 507.46 (80.16%) | 299.727 (47.35%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 613.056 | 312.257 (50.93%) | 491.427 (80.16%) | 349.624 (57.03%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 672.343 | 401.493 (59.72%) | 536.009 (79.72%) | 366.587 (54.52%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 751.091 | 391.004 (52.06%) | 553.107 (73.64%) | 357.348 (47.58%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 471.992 | 219.219 (46.45%) | 390.074 (82.64%) | 220.613 (46.74%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 389.98 | 243.137 (62.35%) | 393.773 (100.97%) | 240.099 (61.57%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 498.224 | 270.748 (54.34%) | 413.169 (82.93%) | 239.81 (48.13%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 473.244 | 264.137 (55.81%) | 404.26 (85.42%) | 234.646 (49.58%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 454.63 | 233.759 (51.42%) | 340.896 (74.98%) | 215.727 (47.45%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 466.233 | 250.553 (53.74%) | 413.515 (88.69%) | 270.758 (58.07%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 628.777 | 227.461 (36.18%) | 435.455 (69.25%) | 279.023 (44.38%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 593.596 | 271.837 (45.79%) | 439.236 (74%) | 273.872 (46.14%) |
EishayParseUTF8Bytes
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 1007.895 | 792.706 (78.65%) | 601.167 (59.65%) | 312.282 (30.98%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 1079.838 | 748.275 (69.3%) | 569.282 (52.72%) | 318.086 (29.46%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 1170.334 | 957.492 (81.81%) | 563.368 (48.14%) | 323.771 (27.66%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1130.077 | 913.014 (80.79%) | 552.507 (48.89%) | 313.943 (27.78%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 871.885 | 776.46 (89.06%) | 605.887 (69.49%) | 325.64 (37.35%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 1074.038 | 714.496 (66.52%) | 585.879 (54.55%) | 358.034 (33.34%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 1121.149 | 920.904 (82.14%) | 645.843 (57.61%) | 375.075 (33.45%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 1123.642 | 896.926 (79.82%) | 585.644 (52.12%) | 376.076 (33.47%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 736.065 | 564.252 (76.66%) | 466.792 (63.42%) | 238.31 (32.38%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 756.791 | 589.247 (77.86%) | 437.036 (57.75%) | 257.932 (34.08%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 787.365 | 757.695 (96.23%) | 443.791 (56.36%) | 253.569 (32.2%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 741.989 | 742.438 (100.06%) | 423.982 (57.14%) | 252.575 (34.04%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 789.342 | 656.088 (83.12%) | 403.818 (51.16%) | 230.501 (29.2%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 951.633 | 669.133 (70.31%) | 487.891 (51.27%) | 280.795 (29.51%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 997.926 | 822.066 (82.38%) | 440.564 (44.15%) | 264.536 (26.51%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 947.491 | 403.878 (42.63%) | 459.864 (48.53%) | 268.192 (28.31%) |
EishayParseUTF8BytesPretty
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 781.948 | 242.36 (30.99%) | 547.843 (70.06%) | 288.135 (36.85%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 854.232 | 226.409 (26.5%) | 499.524 (58.48%) | 297.611 (34.84%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 893.135 | 271.719 (30.42%) | 506.877 (56.75%) | 293.033 (32.81%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 881.877 | 262.445 (29.76%) | 498.117 (56.48%) | 302.64 (34.32%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 733.01 | 252.628 (34.46%) | 537.094 (73.27%) | 300.897 (41.05%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 821.442 | 232.378 (28.29%) | 521.836 (63.53%) | 346.713 (42.21%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 851.736 | 274.559 (32.24%) | 534.161 (62.71%) | 362.824 (42.6%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 837.475 | 258.522 (30.87%) | 517.147 (61.75%) | 353.449 (42.2%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 607.068 | 188.759 (31.09%) | 414.054 (68.21%) | 221.13 (36.43%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 596.348 | 191.041 (32.04%) | 397.845 (66.71%) | 239.818 (40.21%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 618.79 | 216.209 (34.94%) | 403.615 (65.23%) | 238.153 (38.49%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 585.396 | 207.05 (35.37%) | 382.894 (65.41%) | 233.914 (39.96%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 642.041 | 205.154 (31.95%) | 373.797 (58.22%) | 226.379 (35.26%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 705.93 | 172.783 (24.48%) | 428.821 (60.75%) | 280.867 (39.79%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 760.451 | 246.174 (32.37%) | 339.103 (44.59%) | 278.505 (36.62%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 731.945 | 230.424 (31.48%) | 404.912 (55.32%) | 271.972 (37.16%) |
EishayWriteBinary
| fastjson2JSONB | fastjson2JSONBArrayMapping | fastjson2UTF8Bytes | hessian | javaSerialize | kryo | |
|---|---|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 2089.541 | 3564.11 (170.57%) | 1514.287 (72.47%) | 340.354 (16.29%) | 234.445 (11.22%) | 1894.159 (90.65%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 1874.417 | 3300.954 (176.11%) | 1578.127 (84.19%) | 332.313 (17.73%) | 213.018 (11.36%) | 1999.114 (106.65%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 2392.934 | 3538.57 (147.88%) | 1862.965 (77.85%) | 327.644 (13.69%) | 225.097 (9.41%) | 1883.807 (78.72%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 2671.444 | 4146.813 (155.23%) | 1826.026 (68.35%) | 322.0 (12.05%) | 228.778 (8.56%) | 1791.639 (67.07%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 1974.788 | 3198.107 (161.95%) | 1501.581 (76.04%) | 404.944 (20.51%) | 233.552 (11.83%) | 1721.281 (87.16%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 2002.629 | 3057.324 (152.67%) | 1615.929 (80.69%) | 390.809 (19.51%) | 231.624 (11.57%) | 2023.606 (101.05%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 2006.331 | 3060.099 (152.52%) | 1748.082 (87.13%) | 393.999 (19.64%) | 263.166 (13.12%) | 1877.674 (93.59%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 2339.252 | 4105.642 (175.51%) | 1712.746 (73.22%) | 395.062 (16.89%) | 263.797 (11.28%) | 1727.243 (73.84%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 1329.03 | 1893.759 (142.49%) | 1106.65 (83.27%) | 297.522 (22.39%) | 177.457 (13.35%) | 1112.424 (83.7%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 1481.511 | 2317.027 (156.4%) | 1167.279 (78.79%) | 315.597 (21.3%) | 191.475 (12.92%) | 1307.825 (88.28%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 1436.581 | 2231.718 (155.35%) | 1166.442 (81.2%) | 314.442 (21.89%) | 182.75 (12.72%) | 1229.222 (85.57%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 1615.477 | 2671.895 (165.39%) | 1151.644 (71.29%) | 300.776 (18.62%) | 187.698 (11.62%) | 1283.32 (79.44%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 1582.723 | 2365.753 (149.47%) | 1315.149 (83.09%) | 353.848 (22.36%) | 204.986 (12.95%) | 1406.243 (88.85%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 1746.516 | 2742.957 (157.05%) | 1365.681 (78.19%) | 345.917 (19.81%) | 217.863 (12.47%) | 1578.769 (90.4%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 1557.183 | 2763.317 (177.46%) | 1373.414 (88.2%) | 333.79 (21.44%) | 207.745 (13.34%) | 1437.556 (92.32%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 1869.19 | 3130.223 (167.46%) | 1420.291 (75.98%) | 331.982 (17.76%) | 221.61 (11.86%) | 1450.258 (77.59%) |
EishayWriteString
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 1594.067 | 602.782 (37.81%) | 1000.833 (62.78%) | 321.77 (20.19%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 1312.815 | 588.55 (44.83%) | 895.534 (68.21%) | 279.884 (21.32%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 1724.764 | 595.851 (34.55%) | 1003.889 (58.2%) | 201.488 (11.68%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1692.844 | 606.628 (35.83%) | 911.781 (53.86%) | 204.551 (12.08%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 1608.664 | 634.635 (39.45%) | 940.409 (58.46%) | 358.943 (22.31%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 1392.738 | 609.252 (43.74%) | 949.87 (68.2%) | 276.112 (19.83%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 1722.82 | 631.608 (36.66%) | 962.698 (55.88%) | 336.085 (19.51%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 1675.432 | 625.995 (37.36%) | 863.455 (51.54%) | 320.337 (19.12%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 1048.815 | 468.054 (44.63%) | 583.29 (55.61%) | 272.187 (25.95%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 1040.751 | 414.676 (39.84%) | 605.766 (58.2%) | 248.18 (23.85%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 1182.715 | 483.335 (40.87%) | 625.779 (52.91%) | 190.066 (16.07%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 1132.674 | 438.153 (38.68%) | 599.155 (52.9%) | 191.248 (16.88%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 1199.941 | 494.567 (41.22%) | 629.443 (52.46%) | 318.844 (26.57%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 1170.159 | 437.118 (37.36%) | 675.108 (57.69%) | 282.698 (24.16%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 1365.279 | 453.461 (33.21%) | 593.569 (43.48%) | 172.837 (12.66%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 1259.768 | 404.848 (32.14%) | 487.76 (38.72%) | 192.774 (15.3%) |
EishayWriteUTF8Bytes
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 1500.725 | 576.359 (38.41%) | 877.618 (58.48%) | 291.73 (19.44%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 1609.132 | 546.969 (33.99%) | 857.233 (53.27%) | 270.863 (16.83%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 1857.1 | 547.515 (29.48%) | 940.587 (50.65%) | 198.363 (10.68%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1846.09 | 545.891 (29.57%) | 921.714 (49.93%) | 204.049 (11.05%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 1485.105 | 567.027 (38.18%) | 816.541 (54.98%) | 318.51 (21.45%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 1707.0 | 550.816 (32.27%) | 823.758 (48.26%) | 285.639 (16.73%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 1790.54 | 579.849 (32.38%) | 871.196 (48.66%) | 332.591 (18.57%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 1767.647 | 541.4 (30.63%) | 854.338 (48.33%) | 322.366 (18.24%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 1109.141 | 414.868 (37.4%) | 572.81 (51.64%) | 234.942 (21.18%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 1164.459 | 373.502 (32.08%) | 549.537 (47.19%) | 241.61 (20.75%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 1165.745 | 412.769 (35.41%) | 612.319 (52.53%) | 187.419 (16.08%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 1162.026 | 347.348 (29.89%) | 581.091 (50.01%) | 189.175 (16.28%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 1320.933 | 432.369 (32.73%) | 651.86 (49.35%) | 280.347 (21.22%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 1361.455 | 426.038 (31.29%) | 539.726 (39.64%) | 296.669 (21.79%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 1376.043 | 481.959 (35.02%) | 667.884 (48.54%) | 179.177 (13.02%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 1350.5 | 369.988 (27.4%) | 610.071 (45.17%) | 204.372 (15.13%) |
Benchmark Benchmark 2.0.13 02 (`docs/benchmark/benchmark_2.0.13_02.md`)
EishayParseBinary
| fastjson2JSONB | fastjson2JSONBArrayMapping | fastjson2UTF8Bytes | hessian | javaSerialize | kryo | |
|---|---|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 1782.133 | 2525.458 (141.71%) | 1056.124 (59.26%) | 276.081 (15.49%) | 46.39 (2.6%) | 1733.176 (97.25%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 2342.848 | 3699.756 (157.92%) | 1165.912 (49.76%) | 248.263 (10.6%) | 47.482 (2.03%) | 1663.107 (70.99%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 2388.776 | 3658.102 (153.14%) | 1249.376 (52.3%) | 254.68 (10.66%) | 54.3 (2.27%) | 1537.466 (64.36%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 2538.835 | 3709.856 (146.12%) | 1251.876 (49.31%) | 246.993 (9.73%) | 51.667 (2.04%) | 1626.053 (64.05%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 1330.049 | 1724.024 (129.62%) | 927.697 (69.75%) | 252.443 (18.98%) | 43.878 (3.3%) | 1631.529 (122.67%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 1971.151 | 3265.762 (165.68%) | 1150.115 (58.35%) | 247.993 (12.58%) | 46.621 (2.37%) | 1601.701 (81.26%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 2367.342 | 3513.084 (148.4%) | 1201.407 (50.75%) | 251.254 (10.61%) | 54.032 (2.28%) | 1704.836 (72.01%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 2394.957 | 3661.618 (152.89%) | 1157.298 (48.32%) | 246.139 (10.28%) | 51.986 (2.17%) | 1631.987 (68.14%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 1420.831 | 2106.132 (148.23%) | 754.07 (53.07%) | 191.895 (13.51%) | 36.924 (2.6%) | 1296.399 (91.24%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 1611.312 | 2502.047 (155.28%) | 784.596 (48.69%) | 180.879 (11.23%) | 37.465 (2.33%) | 1249.564 (77.55%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 1498.639 | 2170.96 (144.86%) | 796.26 (53.13%) | 207.647 (13.86%) | 38.977 (2.6%) | 1217.007 (81.21%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 1479.013 | 2167.699 (146.56%) | 751.424 (50.81%) | 187.644 (12.69%) | 39.024 (2.64%) | 1203.53 (81.37%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 1390.519 | 2167.525 (155.88%) | 813.783 (58.52%) | 214.349 (15.42%) | 42.108 (3.03%) | 1194.59 (85.91%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 1992.768 | 3087.692 (154.94%) | 1028.149 (51.59%) | 202.663 (10.17%) | 39.192 (1.97%) | 1408.442 (70.68%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 1803.467 | 2668.26 (147.95%) | 1026.099 (56.9%) | 218.999 (12.14%) | 38.592 (2.14%) | 1281.537 (71.06%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 1771.182 | 2655.597 (149.93%) | 1005.776 (56.79%) | 193.893 (10.95%) | 41.41 (2.34%) | 1306.851 (73.78%) |
EishayParseString
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 1205.828 | 1001.702 (83.07%) | 521.798 (43.27%) | 445.069 (36.91%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 1178.222 | 915.729 (77.72%) | 522.275 (44.33%) | 440.35 (37.37%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 1321.291 | 1255.134 (94.99%) | 500.261 (37.86%) | 458.404 (34.69%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1292.052 | 1194.397 (92.44%) | 492.705 (38.13%) | 434.652 (33.64%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 1102.048 | 1018.063 (92.38%) | 534.665 (48.52%) | 454.969 (41.28%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 1160.332 | 883.222 (76.12%) | 485.824 (41.87%) | 431.128 (37.16%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 1265.438 | 1256.855 (99.32%) | 530.051 (41.89%) | 529.319 (41.83%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 1259.068 | 1228.805 (97.6%) | 518.889 (41.21%) | 469.497 (37.29%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 861.622 | 716.671 (83.18%) | 385.228 (44.71%) | 313.904 (36.43%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 850.546 | 738.641 (86.84%) | 374.49 (44.03%) | 319.943 (37.62%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 868.35 | 1018.95 (117.34%) | 378.838 (43.63%) | 318.735 (36.71%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 870.516 | 987.834 (113.48%) | 360.669 (41.43%) | 301.779 (34.67%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 911.183 | 735.028 (80.67%) | 367.242 (40.3%) | 354.038 (38.85%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 1068.053 | 809.122 (75.76%) | 413.986 (38.76%) | 376.447 (35.25%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 1113.751 | 1142.671 (102.6%) | 404.27 (36.3%) | 354.388 (31.82%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 1113.672 | 1117.071 (100.31%) | 397.524 (35.69%) | 336.629 (30.23%) |
EishayParseStringPretty
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 914.913 | 260.948 (28.52%) | 488.534 (53.4%) | 405.062 (44.27%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 869.537 | 240.336 (27.64%) | 478.308 (55.01%) | 408.671 (47%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 949.093 | 290.443 (30.6%) | 466.263 (49.13%) | 406.06 (42.78%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 952.949 | 284.089 (29.81%) | 447.362 (46.95%) | 386.428 (40.55%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 926.693 | 280.81 (30.3%) | 482.434 (52.06%) | 425.555 (45.92%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 796.905 | 251.113 (31.51%) | 438.676 (55.05%) | 441.839 (55.44%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 858.64 | 301.413 (35.1%) | 488.018 (56.84%) | 494.709 (57.62%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 866.872 | 294.802 (34.01%) | 450.718 (51.99%) | 398.227 (45.94%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 679.741 | 208.971 (30.74%) | 348.709 (51.3%) | 284.181 (41.81%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 652.73 | 213.228 (32.67%) | 345.748 (52.97%) | 295.307 (45.24%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 667.934 | 242.556 (36.31%) | 338.156 (50.63%) | 294.819 (44.14%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 668.713 | 230.108 (34.41%) | 330.814 (49.47%) | 277.149 (41.45%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 718.612 | 211.842 (29.48%) | 342.802 (47.7%) | 325.043 (45.23%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 769.068 | 227.279 (29.55%) | 383.576 (49.88%) | 340.661 (44.3%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 800.753 | 263.158 (32.86%) | 379.18 (47.35%) | 297.113 (37.1%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 810.539 | 216.471 (26.71%) | 365.666 (45.11%) | 281.433 (34.72%) |
EishayParseTreeString
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 997.085 | 514.434 (51.59%) | 515.766 (51.73%) | 330.637 (33.16%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 763.472 | 401.819 (52.63%) | 429.788 (56.29%) | 328.723 (43.06%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 1037.536 | 574.873 (55.41%) | 504.654 (48.64%) | 321.051 (30.94%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1093.471 | 554.95 (50.75%) | 475.09 (43.45%) | 320.287 (29.29%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 871.687 | 471.634 (54.11%) | 532.624 (61.1%) | 366.673 (42.06%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 773.688 | 416.39 (53.82%) | 450.678 (58.25%) | 374.664 (48.43%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 935.493 | 536.847 (57.39%) | 531.319 (56.8%) | 395.134 (42.24%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 989.41 | 518.318 (52.39%) | 530.752 (53.64%) | 393.144 (39.74%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 575.466 | 307.301 (53.4%) | 358.071 (62.22%) | 256.221 (44.52%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 533.266 | 319.084 (59.84%) | 341.73 (64.08%) | 264.967 (49.69%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 608.504 | 360.084 (59.18%) | 384.894 (63.25%) | 259.676 (42.67%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 614.071 | 338.816 (55.18%) | 374.651 (61.01%) | 256.329 (41.74%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 549.741 | 300.575 (54.68%) | 319.55 (58.13%) | 257.939 (46.92%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 646.111 | 362.515 (56.11%) | 383.485 (59.35%) | 300.264 (46.47%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 771.516 | 412.668 (53.49%) | 420.245 (54.47%) | 296.529 (38.43%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 788.369 | 330.23 (41.89%) | 402.203 (51.02%) | 242.248 (30.73%) |
EishayParseTreeStringPretty
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 770.918 | 442.22 (57.36%) | 460.749 (59.77%) | 334.487 (43.39%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 633.96 | 350.577 (55.3%) | 412.013 (64.99%) | 296.582 (46.78%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 836.781 | 477.257 (57.03%) | 462.518 (55.27%) | 305.552 (36.52%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 810.895 | 482.617 (59.52%) | 419.481 (51.73%) | 308.063 (37.99%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 700.717 | 419.129 (59.81%) | 496.366 (70.84%) | 337.334 (48.14%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 641.154 | 359.637 (56.09%) | 426.938 (66.59%) | 342.832 (53.47%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 760.284 | 469.579 (61.76%) | 458.429 (60.3%) | 376.727 (49.55%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 776.707 | 455.305 (58.62%) | 466.59 (60.07%) | 368.467 (47.44%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 494.952 | 267.691 (54.08%) | 331.433 (66.96%) | 244.487 (49.4%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 458.581 | 274.207 (59.79%) | 320.506 (69.89%) | 245.954 (53.63%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 503.912 | 309.047 (61.33%) | 346.57 (68.78%) | 245.126 (48.64%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 500.358 | 295.022 (58.96%) | 336.867 (67.33%) | 241.366 (48.24%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 468.435 | 275.355 (58.78%) | 301.085 (64.27%) | 248.097 (52.96%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 549.206 | 285.921 (52.06%) | 353.581 (64.38%) | 280.961 (51.16%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 619.073 | 353.212 (57.05%) | 374.091 (60.43%) | 261.332 (42.21%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 628.041 | 336.552 (53.59%) | 373.732 (59.51%) | 234.799 (37.39%) |
EishayParseTreeUTF8Bytes
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 891.39 | 446.418 (50.08%) | 563.344 (63.2%) | 311.9 (34.99%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 746.228 | 367.429 (49.24%) | 543.067 (72.77%) | 317.32 (42.52%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 1061.76 | 478.296 (45.05%) | 571.417 (53.82%) | 322.368 (30.36%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1022.813 | 482.094 (47.13%) | 572.836 (56.01%) | 316.902 (30.98%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 718.877 | 418.991 (58.28%) | 549.764 (76.48%) | 329.743 (45.87%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 702.896 | 366.026 (52.07%) | 566.323 (80.57%) | 358.682 (51.03%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 684.35 | 457.519 (66.85%) | 617.747 (90.27%) | 378.477 (55.3%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 925.719 | 457.977 (49.47%) | 623.411 (67.34%) | 358.934 (38.77%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 533.283 | 249.158 (46.72%) | 436.913 (81.93%) | 238.643 (44.75%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 446.038 | 288.109 (64.59%) | 423.302 (94.9%) | 254.732 (57.11%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 588.767 | 317.48 (53.92%) | 460.976 (78.3%) | 254.623 (43.25%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 556.452 | 301.837 (54.24%) | 421.85 (75.81%) | 252.558 (45.39%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 505.814 | 255.278 (50.47%) | 362.947 (71.76%) | 236.083 (46.67%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 535.746 | 296.398 (55.32%) | 446.352 (83.31%) | 294.35 (54.94%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 763.581 | 354.16 (46.38%) | 494.923 (64.82%) | 278.023 (36.41%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 716.623 | 250.234 (34.92%) | 479.932 (66.97%) | 246.19 (34.35%) |
EishayParseTreeUTF8BytesPretty
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 712.911 | 376.692 (52.84%) | 521.114 (73.1%) | 294.663 (41.33%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 548.909 | 313.585 (57.13%) | 464.385 (84.6%) | 301.081 (54.85%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 858.2 | 417.046 (48.6%) | 519.405 (60.52%) | 294.164 (34.28%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 798.923 | 412.569 (51.64%) | 504.114 (63.1%) | 299.816 (37.53%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 645.567 | 364.863 (56.52%) | 510.062 (79.01%) | 303.512 (47.01%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 576.814 | 310.816 (53.88%) | 496.897 (86.15%) | 343.461 (59.54%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 641.44 | 392.484 (61.19%) | 536.374 (83.62%) | 348.555 (54.34%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 749.963 | 390.087 (52.01%) | 543.789 (72.51%) | 358.217 (47.76%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 471.525 | 220.458 (46.75%) | 387.037 (82.08%) | 221.185 (46.91%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 388.445 | 243.589 (62.71%) | 383.461 (98.72%) | 237.425 (61.12%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 498.764 | 269.244 (53.98%) | 409.465 (82.1%) | 239.235 (47.97%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 474.925 | 257.023 (54.12%) | 393.648 (82.89%) | 233.761 (49.22%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 443.58 | 239.08 (53.9%) | 315.45 (71.11%) | 225.434 (50.82%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 464.079 | 251.514 (54.2%) | 407.993 (87.91%) | 269.426 (58.06%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 626.83 | 263.971 (42.11%) | 453.306 (72.32%) | 282.104 (45%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 596.461 | 270.416 (45.34%) | 434.253 (72.8%) | 276.544 (46.36%) |
EishayParseUTF8Bytes
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 1066.948 | 801.236 (75.1%) | 619.636 (58.08%) | 315.271 (29.55%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 1044.89 | 774.533 (74.13%) | 543.917 (52.05%) | 318.493 (30.48%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 1206.138 | 970.655 (80.48%) | 554.678 (45.99%) | 320.562 (26.58%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1157.73 | 924.841 (79.88%) | 556.489 (48.07%) | 314.354 (27.15%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 906.87 | 797.625 (87.95%) | 584.174 (64.42%) | 331.416 (36.55%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 1075.783 | 722.036 (67.12%) | 605.622 (56.3%) | 368.116 (34.22%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 1184.013 | 911.443 (76.98%) | 616.401 (52.06%) | 382.179 (32.28%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 1169.759 | 905.121 (77.38%) | 586.692 (50.15%) | 370.238 (31.65%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 736.969 | 564.217 (76.56%) | 456.821 (61.99%) | 238.408 (32.35%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 761.945 | 591.618 (77.65%) | 433.845 (56.94%) | 254.018 (33.34%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 796.145 | 757.049 (95.09%) | 447.443 (56.2%) | 253.184 (31.8%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 745.328 | 743.972 (99.82%) | 420.013 (56.35%) | 252.444 (33.87%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 776.416 | 657.574 (84.69%) | 412.723 (53.16%) | 237.956 (30.65%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 963.097 | 672.303 (69.81%) | 453.429 (47.08%) | 292.762 (30.4%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 1035.498 | 748.902 (72.32%) | 440.439 (42.53%) | 277.428 (26.79%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 954.352 | 761.825 (79.83%) | 445.799 (46.71%) | 264.814 (27.75%) |
EishayParseUTF8BytesPretty
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 812.278 | 236.499 (29.12%) | 550.943 (67.83%) | 297.895 (36.67%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 883.054 | 226.931 (25.7%) | 501.137 (56.75%) | 297.278 (33.66%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 892.828 | 271.741 (30.44%) | 509.443 (57.06%) | 304.664 (34.12%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 889.709 | 259.242 (29.14%) | 502.205 (56.45%) | 298.151 (33.51%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 764.416 | 254.523 (33.3%) | 542.973 (71.03%) | 297.028 (38.86%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 819.656 | 230.798 (28.16%) | 501.523 (61.19%) | 339.752 (41.45%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 845.964 | 271.302 (32.07%) | 539.802 (63.81%) | 341.555 (40.37%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 840.005 | 254.842 (30.34%) | 520.85 (62.01%) | 358.89 (42.72%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 608.052 | 191.402 (31.48%) | 416.262 (68.46%) | 219.536 (36.1%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 593.888 | 192.584 (32.43%) | 401.308 (67.57%) | 238.28 (40.12%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 617.14 | 217.084 (35.18%) | 404.213 (65.5%) | 237.076 (38.42%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 586.81 | 206.072 (35.12%) | 383.564 (65.36%) | 233.315 (39.76%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 647.797 | 206.109 (31.82%) | 380.332 (58.71%) | 222.666 (34.37%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 720.545 | 177.412 (24.62%) | 422.096 (58.58%) | 282.955 (39.27%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 753.89 | 239.096 (31.71%) | 317.185 (42.07%) | 281.51 (37.34%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 676.887 | 218.668 (32.3%) | 408.779 (60.39%) | 269.936 (39.88%) |
EishayWriteBinary
| fastjson2JSONB | fastjson2JSONBArrayMapping | fastjson2UTF8Bytes | hessian | javaSerialize | kryo | |
|---|---|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 2071.43 | 3380.615 (163.2%) | 1517.202 (73.24%) | 339.274 (16.38%) | 228.808 (11.05%) | 1812.214 (87.49%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 1875.351 | 3246.085 (173.09%) | 1582.495 (84.38%) | 335.171 (17.87%) | 216.849 (11.56%) | 1992.78 (106.26%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 2401.893 | 3581.923 (149.13%) | 1859.506 (77.42%) | 327.216 (13.62%) | 219.657 (9.15%) | 1869.804 (77.85%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 2621.199 | 3990.308 (152.23%) | 1826.502 (69.68%) | 324.306 (12.37%) | 225.631 (8.61%) | 1721.298 (65.67%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 1979.145 | 3188.919 (161.13%) | 1456.483 (73.59%) | 406.431 (20.54%) | 229.429 (11.59%) | 1749.949 (88.42%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 2011.176 | 3074.91 (152.89%) | 1730.851 (86.06%) | 389.252 (19.35%) | 231.42 (11.51%) | 2060.879 (102.47%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 1909.345 | 3113.187 (163.05%) | 1810.009 (94.8%) | 401.88 (21.05%) | 236.189 (12.37%) | 1922.92 (100.71%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 2420.281 | 3916.682 (161.83%) | 1698.672 (70.18%) | 395.174 (16.33%) | 262.953 (10.86%) | 1651.49 (68.24%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 1332.343 | 1892.29 (142.03%) | 1118.603 (83.96%) | 298.699 (22.42%) | 182.127 (13.67%) | 1108.995 (83.24%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 1476.03 | 2320.792 (157.23%) | 1163.427 (78.82%) | 313.864 (21.26%) | 186.012 (12.6%) | 1304.51 (88.38%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 1430.349 | 2238.388 (156.49%) | 1178.178 (82.37%) | 317.469 (22.2%) | 181.582 (12.69%) | 1238.083 (86.56%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 1613.037 | 2675.155 (165.85%) | 1151.013 (71.36%) | 307.375 (19.06%) | 186.308 (11.55%) | 1284.56 (79.64%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 1578.964 | 2331.498 (147.66%) | 1322.11 (83.73%) | 348.96 (22.1%) | 204.271 (12.94%) | 1434.252 (90.84%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 1724.889 | 2760.723 (160.05%) | 1349.675 (78.25%) | 342.103 (19.83%) | 218.629 (12.67%) | 1570.721 (91.06%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 1756.895 | 2408.2 (137.07%) | 1344.672 (76.54%) | 335.817 (19.11%) | 208.869 (11.89%) | 1425.502 (81.14%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 2010.907 | 3173.497 (157.81%) | 1440.127 (71.62%) | 337.206 (16.77%) | 220.861 (10.98%) | 1449.28 (72.07%) |
EishayWriteString
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 1590.551 | 608.307 (38.25%) | 954.408 (60%) | 329.301 (20.7%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 1303.084 | 592.523 (45.47%) | 932.81 (71.58%) | 274.951 (21.1%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 1724.339 | 611.848 (35.48%) | 974.656 (56.52%) | 201.169 (11.67%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1700.592 | 602.24 (35.41%) | 913.12 (53.69%) | 202.563 (11.91%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 1511.416 | 621.776 (41.14%) | 935.109 (61.87%) | 358.418 (23.71%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 1422.418 | 618.174 (43.46%) | 922.372 (64.85%) | 292.843 (20.59%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 1749.89 | 653.833 (37.36%) | 943.385 (53.91%) | 335.576 (19.18%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 1599.962 | 631.733 (39.48%) | 868.328 (54.27%) | 329.059 (20.57%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 1053.666 | 458.413 (43.51%) | 581.086 (55.15%) | 271.693 (25.79%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 1052.397 | 440.418 (41.85%) | 614.824 (58.42%) | 248.676 (23.63%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 1174.285 | 471.802 (40.18%) | 609.223 (51.88%) | 191.059 (16.27%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 1123.557 | 449.895 (40.04%) | 571.913 (50.9%) | 192.02 (17.09%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 1214.8 | 463.706 (38.17%) | 643.698 (52.99%) | 325.141 (26.76%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 1188.028 | 389.203 (32.76%) | 633.045 (53.29%) | 255.4 (21.5%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 1365.182 | 414.651 (30.37%) | 525.021 (38.46%) | 188.908 (13.84%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 1309.4 | 329.223 (25.14%) | 566.097 (43.23%) | 186.631 (14.25%) |
EishayWriteUTF8Bytes
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 1504.183 | 569.905 (37.89%) | 894.43 (59.46%) | 299.369 (19.9%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 1575.543 | 545.608 (34.63%) | 859.64 (54.56%) | 280.633 (17.81%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 1884.231 | 550.955 (29.24%) | 1006.164 (53.4%) | 204.696 (10.86%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1818.451 | 538.178 (29.6%) | 908.11 (49.94%) | 203.155 (11.17%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 1406.24 | 570.306 (40.56%) | 838.705 (59.64%) | 315.086 (22.41%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 1736.322 | 554.364 (31.93%) | 845.869 (48.72%) | 283.909 (16.35%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 1748.954 | 554.862 (31.73%) | 889.475 (50.86%) | 336.306 (19.23%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 1740.101 | 561.427 (32.26%) | 879.857 (50.56%) | 322.272 (18.52%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 1122.844 | 432.908 (38.55%) | 568.322 (50.61%) | 241.07 (21.47%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 1159.103 | 383.77 (33.11%) | 560.555 (48.36%) | 255.001 (22%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 1178.344 | 423.444 (35.94%) | 603.448 (51.21%) | 185.824 (15.77%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 1173.44 | 343.261 (29.25%) | 572.44 (48.78%) | 186.707 (15.91%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 1326.591 | 437.868 (33.01%) | 649.984 (49%) | 286.03 (21.56%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 1279.936 | 394.419 (30.82%) | 510.763 (39.91%) | 285.945 (22.34%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 1273.709 | 392.094 (30.78%) | 669.208 (52.54%) | 201.22 (15.8%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 1439.419 | 365.445 (25.39%) | 582.997 (40.5%) | 179.264 (12.45%) |
Benchmark Benchmark 2.0.13 03 (`docs/benchmark/benchmark_2.0.13_03.md`)
EishayParseBinary
| fastjson2JSONB | fastjson2JSONBArrayMapping | fastjson2UTF8Bytes | hessian | javaSerialize | kryo | |
|---|---|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 1630.739 | 2500.295 (153.32%) | 1115.691 (68.42%) | 275.46 (16.89%) | 46.515 (2.85%) | 1738.892 (106.63%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 2283.803 | 3638.611 (159.32%) | 1159.064 (50.75%) | 249.08 (10.91%) | 49.026 (2.15%) | 1642.005 (71.9%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 2287.246 | 3564.703 (155.85%) | 1274.75 (55.73%) | 258.165 (11.29%) | 52.832 (2.31%) | 1483.374 (64.85%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 2430.139 | 3799.704 (156.36%) | 1206.716 (49.66%) | 241.058 (9.92%) | 51.799 (2.13%) | 1577.402 (64.91%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 1665.215 | 2509.458 (150.7%) | 1067.966 (64.13%) | 267.557 (16.07%) | 46.99 (2.82%) | 1690.399 (101.51%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 2520.364 | 3932.495 (156.03%) | 1201.083 (47.66%) | 245.609 (9.74%) | 46.009 (1.83%) | 1634.64 (64.86%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 2402.168 | 3563.688 (148.35%) | 1196.725 (49.82%) | 250.014 (10.41%) | 54.354 (2.26%) | 1626.339 (67.7%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 2385.925 | 3644.871 (152.77%) | 1166.58 (48.89%) | 242.615 (10.17%) | 51.049 (2.14%) | 1692.291 (70.93%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 1256.422 | 2111.009 (168.02%) | 726.348 (57.81%) | 186.726 (14.86%) | 37.387 (2.98%) | 1288.593 (102.56%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 1662.933 | 2540.072 (152.75%) | 787.896 (47.38%) | 180.212 (10.84%) | 36.909 (2.22%) | 1267.331 (76.21%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 1500.551 | 2181.312 (145.37%) | 797.698 (53.16%) | 207.529 (13.83%) | 39.379 (2.62%) | 1207.741 (80.49%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 1464.7 | 2159.924 (147.47%) | 753.758 (51.46%) | 187.514 (12.8%) | 39.797 (2.72%) | 1187.78 (81.09%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 1212.13 | 2178.85 (179.75%) | 785.389 (64.79%) | 203.28 (16.77%) | 41.827 (3.45%) | 1200.13 (99.01%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 1989.223 | 3127.413 (157.22%) | 995.331 (50.04%) | 200.001 (10.05%) | 40.925 (2.06%) | 1324.974 (66.61%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 1782.22 | 2689.207 (150.89%) | 984.145 (55.22%) | 212.104 (11.9%) | 40.59 (2.28%) | 1262.032 (70.81%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 1750.555 | 2708.09 (154.7%) | 998.556 (57.04%) | 201.4 (11.5%) | 41.437 (2.37%) | 1244.177 (71.07%) |
EishayParseString
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 1323.736 | 987.867 (74.63%) | 530.164 (40.05%) | 439.605 (33.21%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 1197.273 | 900.397 (75.2%) | 496.584 (41.48%) | 421.977 (35.24%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 1301.334 | 1260.084 (96.83%) | 507.174 (38.97%) | 454.649 (34.94%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1330.822 | 1203.12 (90.4%) | 513.651 (38.6%) | 426.154 (32.02%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 1304.154 | 1050.702 (80.57%) | 519.164 (39.81%) | 473.503 (36.31%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 1183.918 | 944.19 (79.75%) | 470.325 (39.73%) | 472.352 (39.9%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 1226.576 | 1291.671 (105.31%) | 558.511 (45.53%) | 514.801 (41.97%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 1234.001 | 1228.892 (99.59%) | 507.737 (41.15%) | 476.821 (38.64%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 844.345 | 713.329 (84.48%) | 380.643 (45.08%) | 312.097 (36.96%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 854.08 | 741.269 (86.79%) | 377.205 (44.17%) | 321.805 (37.68%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 870.654 | 1018.901 (117.03%) | 371.607 (42.68%) | 319.672 (36.72%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 869.09 | 1003.21 (115.43%) | 365.044 (42%) | 302.661 (34.83%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 889.647 | 747.75 (84.05%) | 381.172 (42.85%) | 356.185 (40.04%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 1051.972 | 822.367 (78.17%) | 418.189 (39.75%) | 372.807 (35.44%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 1101.706 | 1100.021 (99.85%) | 416.938 (37.84%) | 344.408 (31.26%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 1112.139 | 1035.713 (93.13%) | 403.306 (36.26%) | 267.996 (24.1%) |
EishayParseStringPretty
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 949.52 | 271.756 (28.62%) | 465.698 (49.05%) | 406.892 (42.85%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 898.19 | 244.142 (27.18%) | 461.285 (51.36%) | 420.561 (46.82%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 964.395 | 298.147 (30.92%) | 465.43 (48.26%) | 416.179 (43.15%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 963.475 | 284.693 (29.55%) | 462.607 (48.01%) | 398.376 (41.35%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 943.965 | 286.16 (30.31%) | 492.463 (52.17%) | 427.787 (45.32%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 828.089 | 249.341 (30.11%) | 464.408 (56.08%) | 449.28 (54.26%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 841.324 | 307.519 (36.55%) | 492.723 (58.57%) | 471.914 (56.09%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 864.425 | 292.053 (33.79%) | 453.034 (52.41%) | 438.131 (50.68%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 670.527 | 210.883 (31.45%) | 344.712 (51.41%) | 282.961 (42.2%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 654.406 | 210.229 (32.13%) | 346.945 (53.02%) | 295.454 (45.15%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 669.835 | 241.066 (35.99%) | 342.144 (51.08%) | 293.506 (43.82%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 668.966 | 231.296 (34.58%) | 320.197 (47.86%) | 271.467 (40.58%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 716.894 | 214.519 (29.92%) | 349.385 (48.74%) | 318.006 (44.36%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 774.946 | 234.173 (30.22%) | 379.967 (49.03%) | 351.182 (45.32%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 787.316 | 258.379 (32.82%) | 391.892 (49.78%) | 266.433 (33.84%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 768.0 | 248.956 (32.42%) | 373.933 (48.69%) | 290.671 (37.85%) |
EishayParseTreeString
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 957.311 | 515.948 (53.9%) | 491.08 (51.3%) | 342.97 (35.83%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 752.91 | 409.434 (54.38%) | 430.376 (57.16%) | 321.123 (42.65%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 994.776 | 548.345 (55.12%) | 503.563 (50.62%) | 315.843 (31.75%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1067.514 | 550.841 (51.6%) | 517.538 (48.48%) | 317.661 (29.76%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 941.609 | 503.222 (53.44%) | 560.833 (59.56%) | 370.55 (39.35%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 796.332 | 420.249 (52.77%) | 481.012 (60.4%) | 372.637 (46.79%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 1005.837 | 545.24 (54.21%) | 546.863 (54.37%) | 392.377 (39.01%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 1010.891 | 532.322 (52.66%) | 514.232 (50.87%) | 391.862 (38.76%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 577.181 | 305.249 (52.89%) | 359.635 (62.31%) | 256.673 (44.47%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 523.624 | 319.966 (61.11%) | 347.601 (66.38%) | 257.187 (49.12%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 608.262 | 359.835 (59.16%) | 385.281 (63.34%) | 256.333 (42.14%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 614.941 | 342.318 (55.67%) | 364.493 (59.27%) | 253.937 (41.29%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 549.151 | 313.884 (57.16%) | 335.956 (61.18%) | 255.678 (46.56%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 653.337 | 363.535 (55.64%) | 381.854 (58.45%) | 308.268 (47.18%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 762.91 | 403.918 (52.94%) | 428.111 (56.12%) | 297.824 (39.04%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 791.154 | 377.86 (47.76%) | 417.157 (52.73%) | 301.584 (38.12%) |
EishayParseTreeStringPretty
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 775.268 | 439.877 (56.74%) | 477.523 (61.59%) | 322.784 (41.64%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 651.341 | 343.828 (52.79%) | 401.791 (61.69%) | 306.837 (47.11%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 802.607 | 504.317 (62.83%) | 466.997 (58.19%) | 305.508 (38.06%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 856.386 | 465.574 (54.36%) | 432.455 (50.5%) | 304.676 (35.58%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 782.343 | 444.188 (56.78%) | 501.98 (64.16%) | 355.34 (45.42%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 673.802 | 360.992 (53.58%) | 426.765 (63.34%) | 359.634 (53.37%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 747.16 | 453.209 (60.66%) | 493.856 (66.1%) | 345.097 (46.19%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 783.803 | 463.83 (59.18%) | 475.482 (60.66%) | 378.297 (48.26%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 493.459 | 267.467 (54.2%) | 328.557 (66.58%) | 243.55 (49.36%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 454.621 | 274.549 (60.39%) | 325.383 (71.57%) | 251.085 (55.23%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 504.286 | 310.138 (61.5%) | 346.185 (68.65%) | 245.773 (48.74%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 500.892 | 293.256 (58.55%) | 336.865 (67.25%) | 239.557 (47.83%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 463.482 | 279.692 (60.35%) | 316.119 (68.21%) | 235.067 (50.72%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 532.458 | 273.668 (51.4%) | 356.965 (67.04%) | 280.261 (52.64%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 619.654 | 366.284 (59.11%) | 363.559 (58.67%) | 232.573 (37.53%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 628.759 | 338.324 (53.81%) | 377.894 (60.1%) | 188.188 (29.93%) |
EishayParseTreeUTF8Bytes
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 874.689 | 442.594 (50.6%) | 579.122 (66.21%) | 313.379 (35.83%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 633.027 | 366.597 (57.91%) | 503.139 (79.48%) | 310.454 (49.04%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 1023.151 | 486.601 (47.56%) | 555.894 (54.33%) | 319.026 (31.18%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1025.265 | 479.915 (46.81%) | 573.253 (55.91%) | 313.296 (30.56%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 842.485 | 446.724 (53.02%) | 633.593 (75.21%) | 336.206 (39.91%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 732.778 | 375.199 (51.2%) | 562.519 (76.77%) | 358.626 (48.94%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 791.111 | 476.468 (60.23%) | 623.044 (78.76%) | 380.14 (48.05%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 811.775 | 472.814 (58.24%) | 578.498 (71.26%) | 378.102 (46.58%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 531.269 | 249.771 (47.01%) | 437.987 (82.44%) | 239.927 (45.16%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 444.465 | 287.675 (64.72%) | 422.776 (95.12%) | 254.404 (57.24%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 589.774 | 316.757 (53.71%) | 449.727 (76.25%) | 253.268 (42.94%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 556.393 | 302.032 (54.28%) | 433.374 (77.89%) | 252.66 (45.41%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 497.848 | 254.164 (51.05%) | 364.498 (73.21%) | 237.425 (47.69%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 527.668 | 327.796 (62.12%) | 449.125 (85.12%) | 298.465 (56.56%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 782.283 | 296.867 (37.95%) | 482.039 (61.62%) | 278.319 (35.58%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 707.662 | 292.23 (41.3%) | 482.227 (68.14%) | 272.689 (38.53%) |
EishayParseTreeUTF8BytesPretty
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 714.919 | 385.993 (53.99%) | 499.116 (69.81%) | 299.16 (41.85%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 590.579 | 319.042 (54.02%) | 459.565 (77.82%) | 293.401 (49.68%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 815.327 | 409.118 (50.18%) | 500.049 (61.33%) | 295.942 (36.3%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 818.688 | 415.557 (50.76%) | 498.392 (60.88%) | 296.271 (36.19%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 740.619 | 377.46 (50.97%) | 538.194 (72.67%) | 316.002 (42.67%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 626.978 | 313.196 (49.95%) | 502.586 (80.16%) | 349.533 (55.75%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 669.955 | 386.082 (57.63%) | 541.494 (80.83%) | 365.827 (54.6%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 712.432 | 393.554 (55.24%) | 523.516 (73.48%) | 356.042 (49.98%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 471.413 | 217.849 (46.21%) | 404.632 (85.83%) | 219.297 (46.52%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 389.184 | 243.237 (62.5%) | 384.343 (98.76%) | 241.82 (62.14%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 499.544 | 270.874 (54.22%) | 399.74 (80.02%) | 239.267 (47.9%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 473.364 | 263.972 (55.77%) | 393.965 (83.23%) | 234.713 (49.58%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 453.014 | 235.641 (52.02%) | 329.908 (72.83%) | 228.14 (50.36%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 464.04 | 260.613 (56.16%) | 411.746 (88.73%) | 281.293 (60.62%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 622.519 | 228.767 (36.75%) | 446.041 (71.65%) | 282.27 (45.34%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 590.162 | 265.905 (45.06%) | 432.516 (73.29%) | 271.891 (46.07%) |
EishayParseUTF8Bytes
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 1109.775 | 784.268 (70.67%) | 592.415 (53.38%) | 312.928 (28.2%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 1129.674 | 747.768 (66.19%) | 545.059 (48.25%) | 314.913 (27.88%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 1221.44 | 954.107 (78.11%) | 565.049 (46.26%) | 319.079 (26.12%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1142.182 | 907.511 (79.45%) | 558.083 (48.86%) | 311.677 (27.29%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 966.421 | 809.204 (83.73%) | 638.717 (66.09%) | 333.668 (34.53%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 1119.231 | 720.053 (64.33%) | 604.405 (54%) | 363.811 (32.51%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 1158.443 | 934.315 (80.65%) | 647.77 (55.92%) | 385.526 (33.28%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 1155.097 | 896.783 (77.64%) | 587.258 (50.84%) | 377.335 (32.67%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 721.413 | 563.446 (78.1%) | 460.125 (63.78%) | 238.179 (33.02%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 763.079 | 590.669 (77.41%) | 436.843 (57.25%) | 254.044 (33.29%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 794.853 | 757.08 (95.25%) | 436.848 (54.96%) | 253.813 (31.93%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 740.974 | 745.543 (100.62%) | 417.059 (56.29%) | 252.438 (34.07%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 764.076 | 652.316 (85.37%) | 419.426 (54.89%) | 240.804 (31.52%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 978.292 | 689.161 (70.45%) | 467.908 (47.83%) | 292.164 (29.86%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 1010.292 | 625.987 (61.96%) | 466.196 (46.14%) | 295.485 (29.25%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 934.397 | 752.511 (80.53%) | 458.014 (49.02%) | 284.865 (30.49%) |
EishayParseUTF8BytesPretty
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 807.444 | 250.969 (31.08%) | 527.955 (65.39%) | 278.94 (34.55%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 846.664 | 224.025 (26.46%) | 513.4 (60.64%) | 297.51 (35.14%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 914.924 | 266.346 (29.11%) | 513.009 (56.07%) | 301.854 (32.99%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 883.125 | 261.323 (29.59%) | 503.784 (57.05%) | 296.428 (33.57%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 827.715 | 257.91 (31.16%) | 516.871 (62.45%) | 292.025 (35.28%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 804.735 | 231.443 (28.76%) | 499.994 (62.13%) | 329.366 (40.93%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 851.122 | 271.318 (31.88%) | 514.652 (60.47%) | 365.307 (42.92%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 819.418 | 259.48 (31.67%) | 517.596 (63.17%) | 345.068 (42.11%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 601.224 | 189.093 (31.45%) | 414.793 (68.99%) | 220.658 (36.7%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 597.524 | 192.122 (32.15%) | 403.274 (67.49%) | 240.123 (40.19%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 619.211 | 219.718 (35.48%) | 400.621 (64.7%) | 240.63 (38.86%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 583.694 | 207.57 (35.56%) | 384.605 (65.89%) | 235.388 (40.33%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 657.844 | 201.632 (30.65%) | 369.634 (56.19%) | 225.29 (34.25%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 660.103 | 171.929 (26.05%) | 437.587 (66.29%) | 277.848 (42.09%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 755.488 | 245.953 (32.56%) | 402.613 (53.29%) | 278.569 (36.87%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 723.881 | 228.821 (31.61%) | 413.493 (57.12%) | 274.755 (37.96%) |
EishayWriteBinary
| fastjson2JSONB | fastjson2JSONBArrayMapping | fastjson2UTF8Bytes | hessian | javaSerialize | kryo | |
|---|---|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 2165.032 | 3507.354 (162%) | 1497.254 (69.16%) | 334.749 (15.46%) | 224.718 (10.38%) | 1891.848 (87.38%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 2444.528 | 4812.357 (196.86%) | 1585.695 (64.87%) | 333.988 (13.66%) | 202.52 (8.28%) | 1986.647 (81.27%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 3280.823 | 5607.399 (170.91%) | 1869.637 (56.99%) | 322.15 (9.82%) | 227.716 (6.94%) | 1866.643 (56.9%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 3149.7 | 5565.537 (176.7%) | 1825.343 (57.95%) | 321.118 (10.2%) | 224.395 (7.12%) | 1800.361 (57.16%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 2049.037 | 3406.108 (166.23%) | 1534.559 (74.89%) | 411.777 (20.1%) | 242.793 (11.85%) | 1852.706 (90.42%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 2719.317 | 5136.649 (188.89%) | 1808.268 (66.5%) | 400.682 (14.73%) | 239.937 (8.82%) | 2002.049 (73.62%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 2786.386 | 5523.159 (198.22%) | 1823.436 (65.44%) | 413.907 (14.85%) | 256.825 (9.22%) | 1878.784 (67.43%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 2863.441 | 5471.256 (191.07%) | 1771.47 (61.87%) | 417.921 (14.6%) | 263.016 (9.19%) | 1739.421 (60.75%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 1333.009 | 1888.522 (141.67%) | 1113.574 (83.54%) | 296.283 (22.23%) | 177.016 (13.28%) | 1102.878 (82.74%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 1835.787 | 3407.588 (185.62%) | 1168.049 (63.63%) | 320.136 (17.44%) | 190.22 (10.36%) | 1332.93 (72.61%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 1831.695 | 3337.353 (182.2%) | 1169.51 (63.85%) | 318.412 (17.38%) | 179.163 (9.78%) | 1238.286 (67.6%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 1839.155 | 3364.052 (182.91%) | 1168.66 (63.54%) | 312.387 (16.99%) | 194.952 (10.6%) | 1280.178 (69.61%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 1596.165 | 2336.192 (146.36%) | 1324.459 (82.98%) | 349.792 (21.91%) | 207.085 (12.97%) | 1443.016 (90.41%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 1891.348 | 4037.545 (213.47%) | 1368.906 (72.38%) | 340.011 (17.98%) | 220.334 (11.65%) | 1509.409 (79.81%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 2038.768 | 4267.276 (209.31%) | 1266.263 (62.11%) | 337.729 (16.57%) | 209.79 (10.29%) | 1460.236 (71.62%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 2336.628 | 2937.54 (125.72%) | 1426.487 (61.05%) | 345.045 (14.77%) | 224.138 (9.59%) | 1465.891 (62.74%) |
EishayWriteString
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 1597.334 | 617.074 (38.63%) | 971.138 (60.8%) | 329.705 (20.64%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 1314.718 | 570.865 (43.42%) | 918.09 (69.83%) | 279.339 (21.25%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 1707.094 | 607.125 (35.56%) | 1015.381 (59.48%) | 204.783 (12%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1695.635 | 606.675 (35.78%) | 912.111 (53.79%) | 204.64 (12.07%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 1656.294 | 648.456 (39.15%) | 960.727 (58%) | 376.564 (22.74%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 1454.849 | 623.04 (42.83%) | 967.079 (66.47%) | 275.028 (18.9%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_x64 | 1789.568 | 637.608 (35.63%) | 972.532 (54.34%) | 342.085 (19.12%) |
| ecs.c7a.xlarge-oracle-jdk-18.0.2_x64 | 1650.187 | 625.512 (37.91%) | 875.175 (53.03%) | 316.477 (19.18%) |
| ecs.c6r.xlarge-oracle-jdk1.8.0_341_aarch64 | 1049.284 | 463.809 (44.2%) | 579.294 (55.21%) | 275.693 (26.27%) |
| ecs.c6r.xlarge-oracle-jdk-11.0.16_aarch64 | 1063.189 | 416.973 (39.22%) | 599.63 (56.4%) | 248.815 (23.4%) |
| ecs.c6r.xlarge-oracle-jdk-17.0.4_aarch64 | 1169.558 | 475.121 (40.62%) | 622.426 (53.22%) | 191.708 (16.39%) |
| ecs.c6r.xlarge-oracle-jdk-18.0.2_aarch64 | 1128.086 | 430.75 (38.18%) | 588.999 (52.21%) | 190.541 (16.89%) |
| ecs.g8m.xlarge-oracle-jdk1.8.0_341_aarch64 | 1216.316 | 466.66 (38.37%) | 640.654 (52.67%) | 331.443 (27.25%) |
| ecs.g8m.xlarge-oracle-jdk-11.0.16_aarch64 | 1186.383 | 321.804 (27.12%) | 588.116 (49.57%) | 206.258 (17.39%) |
| ecs.g8m.xlarge-oracle-jdk-17.0.4_aarch64 | 1277.182 | 437.705 (34.27%) | 588.362 (46.07%) | 196.22 (15.36%) |
| ecs.g8m.xlarge-oracle-jdk-18.0.2_aarch64 | 1250.542 | 387.489 (30.99%) | 643.238 (51.44%) | 186.391 (14.9%) |
EishayWriteUTF8Bytes
| fastjson2 | fastjson1 | jackson | gson | |
|---|---|---|---|---|
| ecs.c7.xlarge-oracle-jdk1.8.0_341_x64 | 1508.784 | 576.176 (38.19%) | 901.375 (59.74%) | 286.079 (18.96%) |
| ecs.c7.xlarge-oracle-jdk-11.0.16_x64 | 1589.998 | 536.881 (33.77%) | 827.221 (52.03%) | 271.859 (17.1%) |
| ecs.c7.xlarge-oracle-jdk-17.0.4_x64 | 1842.546 | 559.337 (30.36%) | 976.469 (53%) | 201.578 (10.94%) |
| ecs.c7.xlarge-oracle-jdk-18.0.2_x6 | 1855.697 | 544.391 (29.34%) | 919.788 (49.57%) | 203.188 (10.95%) |
| ecs.c7a.xlarge-oracle-jdk1.8.0_341_x64 | 1443.064 | 575.83 (39.9%) | 834.834 (57.85%) | 342.996 (23.77%) |
| ecs.c7a.xlarge-oracle-jdk-11.0.16_x64 | 1778.869 | 557.6 (31.35%) | 867.593 (48.77%) | 273.9 (15.4%) |
| ecs.c7a.xlarge-oracle-jdk-17.0.4_ |