Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ It covers the following libraries:
* [dsl-json](https://github.com/ngs-doo/dsl-json)
* [fastjson](https://github.com/alibaba/fastjson)
* [flexjson](http://flexjson.sourceforge.net/)
* [fory-json](https://fory.apache.org/docs/json/)
* [genson](https://owlike.github.io/genson/)
* [gson](https://github.com/google/gson)
* [jackson](https://github.com/FasterXML/jackson)
Expand Down
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,8 @@ dependencies {
implementation 'com.alibaba.fastjson2:fastjson2:2.0.57'
// FlexJson
implementation 'net.sf.flexjson:flexjson:3.3'
// Fory JSON
implementation 'org.apache.fory:fory-json:1.6.0'
// GENSON
implementation 'com.owlike:genson:1.6'
// GSON
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/github/fabienrenaud/jjb/JsonBench.java
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public Object flexjson() throws Exception {
return null;
}

public Object foryjson() throws Exception {
return null;
}

public Object fastjson() throws Exception {
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,12 @@ public Object flexjson() throws JsonSyntaxException {
return JSON_SOURCE().provider().flexjsonDeser().deserialize(JSON_SOURCE().nextReader(), JSON_SOURCE().pojoType());
}

@Benchmark
@Override
public Object foryjson() {
return JSON_SOURCE().provider().foryJson().fromJson(JSON_SOURCE().nextByteArray(), JSON_SOURCE().pojoType());
}

@Benchmark
@Override
public Object boon() throws Exception {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@ public Object flexjson() {
return b;
}

@Benchmark
@Override
public Object foryjson() {
ByteArrayOutputStream baos = JsonUtils.byteArrayOutputStream();
JSON_SOURCE().provider().foryJson().writeJsonTo(JSON_SOURCE().nextPojo(), baos);
return baos;
}

@Benchmark
@Override
public Object boon() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public void transform(Object o) {
.use(LocalDate.class, (objectBinder, o, type, aClass) -> LocalDate.parse((String) o))
.use(OffsetDateTime.class, (objectBinder, o, type, aClass) -> OffsetDateTime.parse((String) o));

private final org.apache.fory.json.ForyJson foryJson = org.apache.fory.json.ForyJson.builder().build();
private final org.boon.json.ObjectMapper boon = org.boon.json.JsonFactory.create();
private final Mapper johnzon;
private final com.squareup.moshi.JsonAdapter<Clients> moshi =
Expand Down Expand Up @@ -233,6 +234,11 @@ public JSONSerializer flexjsonSer() {
return FLEXJSON_SER.get();
}

@Override
public org.apache.fory.json.ForyJson foryJson() {
return foryJson;
}

@Override
public org.boon.json.ObjectMapper boon() {
return boon;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ public interface JsonProvider<T> {

JSONSerializer flexjsonSer();

org.apache.fory.json.ForyJson foryJson();

org.boon.json.ObjectMapper boon();

Mapper johnzon();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public class UsersJsonProvider implements JsonProvider<Users> {
.withProvider(new org.glassfish.json.JsonProviderImpl())
.build();
private final JSONDeserializer<Users> flexjsonDeser = new JSONDeserializer<>();
private final org.apache.fory.json.ForyJson foryJson = org.apache.fory.json.ForyJson.builder().build();
private final org.boon.json.ObjectMapper boon = org.boon.json.JsonFactory.create();
private final org.apache.johnzon.mapper.Mapper johnzon;
private final com.squareup.moshi.JsonAdapter<Users> moshi = new Moshi.Builder().build().adapter(Users.class);
Expand Down Expand Up @@ -123,6 +124,11 @@ public flexjson.JSONSerializer flexjsonSer() {
return FLEXJSON_SER.get();
}

@Override
public org.apache.fory.json.ForyJson foryJson() {
return foryJson;
}

@Override
public org.boon.json.ObjectMapper boon() {
return boon;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ public enum BenchSupport {
new Libapi(Library.JAKARTAJSON, Api.STREAM),
new Libapi(Library.FLEXJSON, Api.DATABIND),
new Libapi(Library.FASTJSON, Api.DATABIND),
new Libapi(Library.FORYJSON, Api.DATABIND),
new Libapi(Library.JSONIO, Api.DATABIND, Api.STREAM),
new Libapi(Library.BOON, Api.DATABIND),
new Libapi(Library.JOHNZON, Api.DATABIND),
Expand Down Expand Up @@ -52,6 +53,7 @@ public enum BenchSupport {
new Libapi(Library.JAKARTAJSON),
new Libapi(Library.FLEXJSON, Api.DATABIND),
new Libapi(Library.FASTJSON, Api.DATABIND),
new Libapi(Library.FORYJSON, Api.DATABIND),
new Libapi(Library.JSONIO, Api.DATABIND),
new Libapi(false, Library.BOON, Api.DATABIND),
new Libapi(false, Library.JOHNZON, Api.DATABIND),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public enum Library {
JAKARTAJSON,
FLEXJSON,
FASTJSON,
FORYJSON,
JSONIO,
BOON,
JOHNZON,
Expand Down
7 changes: 7 additions & 0 deletions src/test/java/com/github/fabienrenaud/jjb/JsonBenchmark.java
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,13 @@ public void fastjson() throws Exception {
}
}

@Test
public void foryjson() throws Exception {
for (int i = 0; i < ITERATIONS; i++) {
test(Library.FORYJSON, BENCH.foryjson());
}
}

@Test
public void jsonio() throws Exception {
for (int i = 0; i < ITERATIONS; i++) {
Expand Down
Loading