apache/seatunnel · error · RuntimeException
Json deserialization exception.
Error message
Json deserialization exception.
What it means
JsonUtils.parseArray catches IOException from Jackson readTree — thrown when the text is not valid JSON or cannot be read — and rethrows it as this RuntimeException, so it marks the input as unparsable JSON for array parsing.
Source
Thrown at seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/JsonUtils.java:286
return parseObject(text.getBytes(StandardCharsets.UTF_8));
}
public static ObjectNode parseObject(byte[] content) {
try {
return (ObjectNode) OBJECT_MAPPER.readTree(content);
} catch (IOException e) {
throw new RuntimeException(
"String json deserialization exception."
+ new String(content, StandardCharsets.UTF_8),
e);
}
}
public static ArrayNode parseArray(String text) {
try {
return (ArrayNode) OBJECT_MAPPER.readTree(text);
} catch (Exception e) {
throw new RuntimeException("Json deserialization exception.", e);
}
}
/** json serializer */
public static class JsonDataSerializer extends JsonSerializer<String> {
@Override
public void serialize(String value, JsonGenerator gen, SerializerProvider provider)
throws IOException {
gen.writeRawValue(value);
}
}
/** json data deserializer */
public static class JsonDataDeserializer extends JsonDeserializer<String> {
@Override
public String deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {View on GitHub (pinned to cf67b549a7)
Solutions
- Inspect the chained cause and the input string; confirm the text starts with '['
- Handle empty input explicitly before calling parseArray
- If the source may return an object wrapper, read it as ObjectNode and extract the array field instead
- Fix JSON syntax issues (trailing commas, single quotes, comments) in the producer
Example fix
// before
ArrayNode arr = JsonUtils.parseArray(""); // blank input throws
// after
ArrayNode arr = text == null || text.isBlank() ? null : JsonUtils.parseArray(text); Defensive patterns
Strategy: type-guard
Validate before calling
ArrayNode safeParseArray(String text) {
if (text == null || text.isBlank()) return null;
try {
JsonNode n = JsonUtils.parseObject(text.getBytes(StandardCharsets.UTF_8));
return n != null && n.isArray() ? (ArrayNode) n : null;
} catch (RuntimeException e) { return null; }
} Type guard
boolean isArrayPayload(String text) { return text != null && text.trim().startsWith("["); } Try / catch
try {
ArrayNode arr = JsonUtils.parseArray(text);
} catch (RuntimeException e) {
log.error("invalid array json: {}", e.getCause());
arr = JsonUtils.getNodeFactory().arrayNode();
} Prevention
- Check the first non-whitespace char is '[' before parsing as an array
- Handle blank responses explicitly
- Fix trailing commas/comments at the producing side, not by regex-repairing at parse time
When it happens
Trigger: Calling JsonUtils.parseArray(text) with malformed JSON, an empty/blank string, or a JSON object/scalar which readTree cannot produce an ArrayNode from (leading to ClassCastException or parse error).
Common situations: Consuming third-party list endpoints that sometimes return a single object, reading JSON arrays from files with trailing commas or comments, blank responses from failed requests.
Understand the failure class
Background: JSON parse error: "Unexpected token" / "not valid JSON" / "failed to parse" — what JSON parsers are really complaining about — this error's family across 45 libraries.
Related errors
- Json parse object exception!
- Json parse list exception!
- json to map exception!
- Json parse object exception.
- String json deserialization exception.<content>
AI-assisted analysis of apache/seatunnel@cf67b549a7 (2026-09-10).
Data as JSON: /api/errors/b7c2970bbdae5571.
Report an issue: GitHub.