Skip to content

Commit

Permalink
Update libraries (#105)
Browse files Browse the repository at this point in the history
  • Loading branch information
Philzen authored May 30, 2024
1 parent 0141397 commit 4e95229
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 62 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ The results here-below were computed on January the 30th, 2024 with the followin
| jodd json | 6.0.3 |
| johnzon | 1.2.21 |
| jakarta | 2.1.3 |
| json-io | 4.40.0 |
| json-io | 4.24.0 |
| simplejson | 1.1.1 |
| json-smart | 2.4.11 |
| logansquare | 1.3.7 |
Expand Down Expand Up @@ -194,4 +194,4 @@ Pull requests are welcome.
[graph-users-deser]: https://docs.google.com/spreadsheets/d/e/2PACX-1vQDBLUYgQ9BhFL_yxZidD1dRG-VYn2aFjMAwc2p6pl_J72XME4lopY8LcyHzTdC5QhISqIrSdkL-Vyt/pubchart?oid=1217359585&format=image
[graph-users-ser]: https://docs.google.com/spreadsheets/d/e/2PACX-1vQDBLUYgQ9BhFL_yxZidD1dRG-VYn2aFjMAwc2p6pl_J72XME4lopY8LcyHzTdC5QhISqIrSdkL-Vyt/pubchart?oid=296776676&format=image
[graph-clients-deser]: https://docs.google.com/spreadsheets/d/e/2PACX-1vQDBLUYgQ9BhFL_yxZidD1dRG-VYn2aFjMAwc2p6pl_J72XME4lopY8LcyHzTdC5QhISqIrSdkL-Vyt/pubchart?oid=684555912&format=image
[graph-clients-ser]: https://docs.google.com/spreadsheets/d/e/2PACX-1vQDBLUYgQ9BhFL_yxZidD1dRG-VYn2aFjMAwc2p6pl_J72XME4lopY8LcyHzTdC5QhISqIrSdkL-Vyt/pubchart?oid=2004244401&format=image
[graph-clients-ser]: https://docs.google.com/spreadsheets/d/e/2PACX-1vQDBLUYgQ9BhFL_yxZidD1dRG-VYn2aFjMAwc2p6pl_J72XME4lopY8LcyHzTdC5QhISqIrSdkL-Vyt/pubchart?oid=2004244401&format=image
34 changes: 17 additions & 17 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@ repositories {
}

ext {
avajeJsonVersion = '1.9'
jacksonVersion = '2.16.0'
dslJsonVersion = '1.10.0'
johnzonVersion = '1.2.21'
avajeJsonVersion = '1.11'
jacksonVersion = '2.17.1'
dslJsonVersion = '2.0.2'
johnzonVersion = '2.0.1'
jmhVersion = '1.35'
}

Expand All @@ -42,8 +42,8 @@ dependencies {
// boon
implementation group: 'io.fastjson', name: 'boon', version: '0.34'
// DSL-json
implementation group: 'com.dslplatform', name: 'dsl-json-java8', version: "${dslJsonVersion}"
annotationProcessor group: 'com.dslplatform', name: 'dsl-json-java8', version: "${dslJsonVersion}"
implementation group: 'com.dslplatform', name: 'dsl-json', version: "${dslJsonVersion}"
annotationProcessor group: 'com.dslplatform', name: 'dsl-json', version: "${dslJsonVersion}"
// FastJson
implementation group: 'com.alibaba.fastjson2', name: 'fastjson2', version: '2.0.48'
implementation group: 'com.alibaba.fastjson2', name: 'fastjson2-incubator-vector', version: '2.0.48'
Expand All @@ -52,7 +52,7 @@ dependencies {
// GENSON
implementation group: 'com.owlike', name: 'genson', version: '1.6'
// GSON
implementation group: 'com.google.code.gson', name: 'gson', version: '2.10.1'
implementation group: 'com.google.code.gson', name: 'gson', version: '2.11.0'
// Jackson
implementation group: 'com.fasterxml.jackson.core', name: 'jackson-databind', version: "${jacksonVersion}"
implementation group: 'com.fasterxml.jackson.module', name: 'jackson-module-afterburner', version: "${jacksonVersion}"
Expand All @@ -61,18 +61,18 @@ dependencies {
// jodd
implementation group: 'org.jodd', name: 'jodd-json', version: '6.0.3'
// johnzon
implementation group: 'org.apache.johnzon', name: 'johnzon-core', classifier: 'jakarta', version: "${johnzonVersion}"
implementation group: 'org.apache.johnzon', name: 'johnzon-mapper', classifier: 'jakarta', version: "${johnzonVersion}"
implementation group: 'org.apache.johnzon', name: 'johnzon-core', version: "${johnzonVersion}"
implementation group: 'org.apache.johnzon', name: 'johnzon-mapper', version: "${johnzonVersion}"
// Jakarta
implementation group: 'jakarta.json.bind', name: 'jakarta.json.bind-api', version: '3.0.0'
implementation group: 'jakarta.json.bind', name: 'jakarta.json.bind-api', version: '3.0.1'
implementation group: 'jakarta.json', name: 'jakarta.json-api', version: '2.1.3'
implementation group: 'org.glassfish', name: 'jakarta.json', version: '2.0.1'
// json-io
implementation group: 'com.cedarsoftware', name: 'json-io', version: '4.14.0'
implementation group: 'com.cedarsoftware', name: 'json-io', version: '4.24.0'
// json-simple
implementation group: 'com.googlecode.json-simple', name: 'json-simple', version: '1.1.1'
// json-smart
implementation group: 'net.minidev', name: 'json-smart', version: '2.4.11'
implementation group: 'net.minidev', name: 'json-smart', version: '2.5.1'
// LoganSquare
implementation group: 'com.bluelinelabs', name: 'logansquare', version: '1.3.7'
annotationProcessor group: 'com.bluelinelabs', name: 'logansquare-compiler', version: '1.3.7'
Expand All @@ -81,19 +81,19 @@ dependencies {
// mjson
implementation group: 'org.sharegov', name: 'mjson', version: '1.4.1'
// moshi
implementation group: 'com.squareup.moshi', name: 'moshi', version: '1.15.0'
implementation group: 'com.squareup.moshi', name: 'moshi', version: '1.15.1'
// nanojson
implementation group: 'com.grack', name: 'nanojson', version: '1.8'
implementation group: 'com.grack', name: 'nanojson', version: '1.9'
// org.json
implementation group: 'org.json', name: 'json', version: '20231013'
implementation group: 'org.json', name: 'json', version: '20240303'
// purejson
implementation group: 'io.github.senthilganeshs', name: 'purejson', version: '1.0.1'
// qson
implementation group: 'io.quarkus.qson', name: 'qson-generator', version: '1.1.1.Final'
// tapestry
implementation group: 'org.apache.tapestry', name: 'tapestry-json', version: '5.8.3'
implementation group: 'org.apache.tapestry', name: 'tapestry-json', version: '5.8.6'
// underscore-java
implementation group: 'com.github.javadev', name: 'underscore', version: '1.97'
implementation group: 'com.github.javadev', name: 'underscore', version: '1.101'
// yasson
implementation group: 'org.eclipse', name: 'yasson', version: '3.0.3'
// QuickBuffers
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.github.fabienrenaud.jjb.provider;

import com.cedarsoftware.util.io.JsonReader;
import com.cedarsoftware.util.io.JsonWriter;
import com.dslplatform.json.DslJson;
import com.dslplatform.json.runtime.Settings;
import com.fasterxml.jackson.core.JsonFactory;
Expand Down Expand Up @@ -46,8 +44,6 @@
import java.time.LocalDate;
import java.time.OffsetDateTime;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

public class ClientsJsonProvider implements JsonProvider<Clients> {
Expand Down Expand Up @@ -158,20 +154,15 @@ public void toJson(com.squareup.moshi.JsonWriter writer, @Nullable OffsetDateTim
private final DslJson<Object> dsljson_reflection = new DslJson<>(Settings.withRuntime());//don't include generated classes

private final io.avaje.jsonb.JsonType<Clients> avajeJsonb_jackson = io.avaje.jsonb.Jsonb
.newBuilder()
.builder()
.adapter(new JacksonAdapter(/* serializeNulls */ true, /* serializeEmpty */ true, /* failOnUnknown */ false)).build().type(Clients.class);
private final io.avaje.jsonb.JsonType<Clients> avajeJsonb_default = io.avaje.jsonb.Jsonb
.newBuilder()
.builder()
.adapter(new JsonStream(/* serializeNulls */ true, /* serializeEmpty */ true, /* failOnUnknown */ false)).build().type(Clients.class);

private final Map<String, Object> jsonioStreamOptions = new HashMap<>();

public ClientsJsonProvider() {

jsonioStreamOptions.put(JsonReader.USE_MAPS, true);
jsonioStreamOptions.put(JsonWriter.TYPE, false);

// set johnson JsonReader (default is `JsonProvider.provider()`)
// set johnzon JsonReader (default is `JsonProvider.provider()`)
jakarta.json.spi.JsonProvider johnzonProvider = new JsonProviderImpl();
johnzon = new org.apache.johnzon.mapper.MapperBuilder()
.setReaderFactory(johnzonProvider.createReaderFactory(Collections.emptyMap()))
Expand Down Expand Up @@ -243,11 +234,6 @@ public Mapper johnzon() {
return johnzon;
}

@Override
public Map<String, Object> jsonioStreamOptions() {
return jsonioStreamOptions;
}

@Override
public DslJson<Object> dsljson() {
return dsljson;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,6 @@
import us.hebi.quickbuf.JsonSink;
import us.hebi.quickbuf.ProtoMessage;

import java.util.Map;

public interface JsonProvider<T> {

Gson gson();
Expand All @@ -42,8 +40,6 @@ public interface JsonProvider<T> {

Mapper johnzon();

Map<String, Object> jsonioStreamOptions();

DslJson<Object> dsljson();

DslJson<Object> dsljson_reflection();
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
package com.github.fabienrenaud.jjb.provider;

import com.cedarsoftware.util.io.JsonReader;
import com.cedarsoftware.util.io.JsonWriter;
import com.dslplatform.json.DslJson;
import com.dslplatform.json.runtime.Settings;
import com.fasterxml.jackson.core.JsonFactory;
Expand All @@ -24,8 +22,6 @@
import org.eclipse.yasson.JsonBindingProvider;

import java.util.Collections;
import java.util.HashMap;
import java.util.Map;

import jakarta.json.bind.Jsonb;
import us.hebi.quickbuf.JsonSink;
Expand Down Expand Up @@ -57,16 +53,12 @@ public class UsersJsonProvider implements JsonProvider<Users> {
private final DslJson<Object> dsljson = new DslJson<>(Settings.withRuntime().includeServiceLoader());
private final DslJson<Object> dsljson_reflection = new DslJson<>(Settings.withRuntime());//don't include generated classes

private final Map<String, Object> jsonioStreamOptions = new HashMap<>();

private final JsonType<Users> avajeJsonb_jackson = io.avaje.jsonb.Jsonb.newBuilder().adapter(new JacksonAdapter(/* serializeNulls */ true, /* serializeEmpty */ true, /* failOnUnknown */ false)).build().type(Users.class);
private final JsonType<Users> avajeJsonb_default = io.avaje.jsonb.Jsonb.newBuilder().adapter(new JsonStream(/* serializeNulls */ true, /* serializeEmpty */ true, /* failOnUnknown */ false)).build().type(Users.class);
private final JsonType<Users> avajeJsonb_jackson = io.avaje.jsonb.Jsonb.builder().adapter(new JacksonAdapter(/* serializeNulls */ true, /* serializeEmpty */ true, /* failOnUnknown */ false)).build().type(Users.class);
private final JsonType<Users> avajeJsonb_default = io.avaje.jsonb.Jsonb.builder().adapter(new JsonStream(/* serializeNulls */ true, /* serializeEmpty */ true, /* failOnUnknown */ false)).build().type(Users.class);

public UsersJsonProvider() {
jsonioStreamOptions.put(JsonReader.USE_MAPS, true);
jsonioStreamOptions.put(JsonWriter.TYPE, false);

// set johnson JsonReader (default is `JsonProvider.provider()`)
// set johnzon JsonReader (default is `JsonProvider.provider()`)
jakarta.json.spi.JsonProvider johnzonProvider = new JsonProviderImpl();
johnzon = new org.apache.johnzon.mapper.MapperBuilder()
.setReaderFactory(johnzonProvider.createReaderFactory(Collections.emptyMap()))
Expand Down Expand Up @@ -132,11 +124,6 @@ public Mapper johnzon() {
return johnzon;
}

@Override
public Map<String, Object> jsonioStreamOptions() {
return jsonioStreamOptions;
}

@Override
public DslJson<Object> dsljson() {
return dsljson;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;

import com.cedarsoftware.io.JsonIo;
import com.cedarsoftware.io.ReadOptionsBuilder;
import org.json.JSONException;
import org.json.JSONObject;
import org.openjdk.jmh.annotations.Benchmark;
Expand Down Expand Up @@ -90,8 +92,14 @@ public Object genson() throws Exception {

@Benchmark
@Override
public Object jsonio() throws Exception {
return com.cedarsoftware.util.io.JsonReader.jsonToJava(JSON_SOURCE().nextInputStream(), JSON_SOURCE().provider().jsonioStreamOptions());
public Object jsonio() {

// returnAsNativeJsonObjects maps to old JsonWriter.USE_MAPS=true behavior,
// see {@link JsonIo#getReadOptionsBuilder(java.util.Map)} and
// <a href="https://github.com/jdereg/json-io/blob/4.19.1/changelog.md">the v4.19 changelog</a>
return JsonIo.toObjects(
JSON_SOURCE().nextInputStream(), new ReadOptionsBuilder().returnAsNativeJsonObjects().build(), null
);
}

@Benchmark
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
import java.io.OutputStreamWriter;
import java.io.Writer;

import com.cedarsoftware.io.JsonIo;
import com.cedarsoftware.io.WriteOptionsBuilder;
import org.openjdk.jmh.annotations.Benchmark;

import com.fasterxml.jackson.core.JsonGenerator;
Expand Down Expand Up @@ -93,8 +95,10 @@ public Object genson() throws Exception {

@Benchmark
@Override
public Object jsonio() throws Exception {
return com.cedarsoftware.util.io.JsonWriter.objectToJson(JSON_SOURCE().nextPojo(), JSON_SOURCE().provider().jsonioStreamOptions());
public Object jsonio() {

// showTypeInfoNever maps to old TYPE=false behavior see {@link JsonIo#getWriteOptionsBuilder(java.util.Map)}
return JsonIo.toJson(JSON_SOURCE().nextPojo(), new WriteOptionsBuilder().showTypeInfoNever().build());
}

@Benchmark
Expand Down
5 changes: 3 additions & 2 deletions src/test/java/com/github/fabienrenaud/jjb/JsonBenchmark.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.github.fabienrenaud.jjb;

import com.cedarsoftware.io.WriteOptionsBuilder;
import com.github.fabienrenaud.jjb.model.Clients;
import com.github.fabienrenaud.jjb.model.Users;
import com.github.fabienrenaud.jjb.support.Api;
Expand Down Expand Up @@ -34,8 +35,8 @@ protected void test(Library lib, Object o) {

if (o instanceof Users || o instanceof Clients) {
testPojo((T) o);
} else if (o instanceof com.cedarsoftware.util.io.JsonObject) {
String v = com.cedarsoftware.util.io.JsonWriter.objectToJson(o, BENCH.JSON_SOURCE().provider().jsonioStreamOptions());
} else if (o instanceof com.cedarsoftware.io.JsonObject) {
String v = com.cedarsoftware.io.JsonIo.toJson(o, new WriteOptionsBuilder().showTypeInfoNever().build());
testString(v);
} else if (o instanceof com.grack.nanojson.JsonObject) {
String v = com.grack.nanojson.JsonWriter.string(o);
Expand Down

0 comments on commit 4e95229

Please sign in to comment.