Validason is a high-performance Java library focused solely on JSON string validation. Rather than providing broad parsing/mapping/tree manipulation like general-purpose JSON libraries, it is optimized for a single purpose: quickly and reliably answering "Is this string valid JSON?"
Gradle:
implementation("io.github.kyu4583:validason:1.0.2")Maven:
<dependency>
<groupId>io.github.kyu4583</groupId>
<artifactId>validason</artifactId>
<version>1.0.2</version>
</dependency>String json = "{\"name\":\"validason\",\"ok\":true}";
boolean ok = Validason.isValid(json);- Fast processing speed, specialized for a single purpose (JSON string validation)
- Extremely low memory allocation
- Simple API with virtually no room for misconfiguration:
Validason.isValid(String)
All figures and graphs below are based on stored benchmark artifacts. Conditions are specified beneath each graph.
BENCH_RUNS=N: each sample is executedNtimes; the run median is usedXms=Xmx=Ng: JVM initial and max heap both fixed atN GB
Six JVM libraries commonly mentioned for JSON string validation were compared under identical conditions.
- Targets:
Jackson,Gson,OrgJson,Jsonp,Moshi,Networknt - Conditions:
length=7–1,000, 500 JSONs per length,BENCH_RUNS=11,Xms=Xmx=4g - Metric: average processing time based on per-length run medians
- All validation functions can be found in
BenchTargets.java
Results:
Jackson:2.03 usJsonp:2.70 usNetworknt:4.14 usGson:4.51 usMoshi:4.62 usOrgJson:11.52 us
In this comparison group, Jackson is the fastest. The rest of this document presents evidence relative to Jackson. The Jackson function used for comparison is the optimal configuration for JSON string validation, described in 2) Usability / Configuration.
What is
AlwaysEscape? A naive baseline that simply iterates over every character and escapes it (seeBenchTargets.alwaysEscapeinbenchmark/). It performs no actual validation — it represents the theoretical lower bound of scanning an entire string once.
- Conditions:
length=7–10,000, 100 JSONs per length,BENCH_RUNS=21,Xms=Xmx=8g - Metric: average processing time based on per-length run medians
Results:
Jackson:19.26 usAlwaysEscape:16.85 usValidason:14.10 us
Relative comparison:
ValidasonvsAlwaysEscape: +16.32% fasterValidasonvsJackson: +26.79% faster
- Conditions:
length=7–2,000, 1,500 JSONs per length,BENCH_RUNS=11,Xms=Xmx=8g - Metric: average processing time based on per-length run medians
Results:
Validason:2.17 usAlwaysEscape:2.18 usJackson:3.17 us
Relative comparison:
ValidasonvsAlwaysEscape: +0.46% fasterValidasonvsJackson: +31.55% faster
All Jackson variants below (readTree, defaultCanonOn, canonOff) are available in BenchTargets.java.
static final ObjectMapper OBJECT_MAPPER = new ObjectMapper();
boolean jacksonReadTree(String json) {
try {
OBJECT_MAPPER.readTree(json);
return true;
} catch (Exception e) {
return false;
}
}
String json = "{\"name\":\"validason\",\"ok\":true}";
boolean ok = jacksonReadTree(json);This is a commonly used pattern for JSON string validation with Jackson.
static final JsonFactory FACTORY_DEFAULT = JsonFactory.builder().build();
boolean jacksonDefaultCanonOn(String json) {
try (JsonParser parser = FACTORY_DEFAULT.createParser(json)) {
while (parser.nextToken() != null) {
// consume
}
return true;
} catch (Exception e) {
return false;
}
}
String json = "{\"name\":\"validason\",\"ok\":true}";
boolean ok = jacksonDefaultCanonOn(json);Generally faster than readTree, but suffers severe performance degradation under high call frequency.
static final JsonFactory FACTORY_CANON_OFF = JsonFactory.builder()
.configure(JsonFactory.Feature.CANONICALIZE_FIELD_NAMES, false)
.build();
boolean jacksonCanonOff(String json) {
try (JsonParser parser = FACTORY_CANON_OFF.createParser(json)) {
while (parser.nextToken() != null) {
// consume
}
return true;
} catch (Exception e) {
return false;
}
}
String json = "{\"name\":\"validason\",\"ok\":true}";
boolean ok = jacksonCanonOff(json);The optimal pattern with no performance degradation even under high call frequency.
String json = "{\"name\":\"validason\",\"ok\":true}";
boolean ok = Validason.isValid(json);Validason's single usage pattern.
Full comparison:
- Conditions:
length=7–1,000, 500 JSONs per length,BENCH_RUNS=1,Xms=Xmx=4g - Results:
Validason:2.70 usJacksonCanonOff:3.35 usJacksonReadTree:11.53 usJacksonDefaultCanonOn:18.34 us
Even for the same "validation" task, Jackson's performance varies significantly depending on implementation and configuration,
while Validason delivers consistent performance with a single isValid call.
Accuracy was verified against JSONTestSuite (y_ valid, n_ invalid), running JacksonCanonOff and JacksonReadTree as independent targets.
Accuracy summary:
Validason:283/283 (100.00%)JacksonCanonOff:279/283 (98.59%)JacksonReadTree:267/283 (94.35%)
All misclassifications are false positives where Jackson variants passed n_ (invalid) files as true.
The 4 misclassifications from JacksonCanonOff also appear in JacksonReadTree.
n_single_space.json
<single space>
n_structure_double_array.json
[][]
n_structure_no_data.json
[][]
n_structure_object_with_trailing_garbage.json
{"a": true} "x"
n_array_comma_after_close.json
[""],
n_array_extra_close.json
["x"]]
n_object_trailing_comment.json
{"a":"b"}/**/
n_object_trailing_comment_open.json
{"a":"b"}/**//
n_object_trailing_comment_slash_open.json
{"a":"b"}//
n_object_trailing_comment_slash_open_incomplete.json
{"a":"b"}/
n_object_with_trailing_garbage.json
{"a":"b"}#
n_string_with_trailing_garbage.json
""x
n_structure_array_trailing_garbage.json
[1]x
n_structure_array_with_extra_array_close.json
[1]]
n_structure_object_followed_by_closing_object.json
{}}
n_structure_trailing_#.json
{"a":"b"}#{}
- Whitespace-only input (
single space) - Multiple top-level structures or no data (
[][]variants) - Trailing garbage/comments/tokens after complete JSON (
"x",#,//,/**/, extra], extra})
In contrast, Validason passed all cases from JSONTestSuite with 100% accuracy.
- Conditions:
length=7–10,000, 100 JSONs per length,BENCH_RUNS=21,Xms=Xmx=8g - Metric: average allocation based on per-length median allocations
Results:
Jackson:11.32 KBAlwaysEscape:5.72 KBValidason:72 B
Validason reduces memory pressure by eliminating unnecessary object creation for string validation.
GC-focused summary:
- Conditions:
length=7–100,000, 5 JSONs per length,BENCH_RUNS=1,Xms=Xmx=32g, single-target runs Samples with GC(bench output): Jackson15 / 499,970, Validason0 / 499,970gc.log Pause event count: Jackson54, Validason23gc.log Pause total: Jackson5425.546 ms, Validason2867.065 msmax-by-length latency point: Jackson24075.0 us, Validason1285.0 us
Reproduction steps are documented in benchmark/README.md.






