quarkusio/quarkus · error · IllegalArgumentException
Json array ended without ]
Error message
Json array ended without ]
What it means
JsonReader.readArray() parses a JSON array character by character and loops consuming elements until it sees ']'. If the input text is exhausted (position reaches end of text) before the closing bracket is found, the loop exits and the parser throws this IllegalArgumentException. It means the JSON array being read was truncated or malformed — e.g. it had a '[' but no matching ']'.
Source
Thrown at core/builder/src/main/java/io/quarkus/builder/JsonReader.java:168
final List<JsonValue> elements = new ArrayList<>();
while (position < length) {
ignoreWhitespace();
switch (peekChar()) {
case ']':
position++;
return new JsonArray(elements);
case ',':
position++;
break;
default:
elements.add(readElement());
break;
}
}
throw new IllegalArgumentException("Json array ended without ]");
}
/**
* string
* |---- '"' characters '"'
* </p>
* characters
* |----- ""
* |----- character characters
* </p>
* character
* |----- '0020' . '10FFFF' - '"' - '\'
* |----- '\' escape
* |----- escape
* |----- '"'
* |----- '\'
* |----- '/'
* |----- 'b'View on GitHub (pinned to e1c734241f)
Solutions
- Validate the JSON with a standard parser (e.g. jakarta.json or Jackson) before feeding it to JsonReader to pinpoint the truncation.
- Inspect the input around the end of each array and add the missing ']' delimiter.
- Check that string values inside the array are properly quoted and escaped so a stray '"' is not swallowing the rest of the array.
- If the JSON comes from a file or template, verify it was written/completed fully (file size, no truncation by the generator).
Example fix
// before
String json = "[{\"name\":\"a\"}"; // missing ]
JsonReader.parse(json);
// after
String json = "[{\"name\":\"a\"}]";
JsonReader.parse(json); Defensive patterns
Strategy: validation
Validate before calling
boolean isBalanced(String json) {
int depth = 0;
boolean inStr = false;
for (int i = 0; i < json.length(); i++) {
char c = json.charAt(i);
if (c == '"' && (i == 0 || json.charAt(i - 1) != '\\')) inStr = !inStr;
if (!inStr && c == '[') depth++;
if (!inStr && c == ']') depth--;
}
return depth == 0 && !inStr;
}
// call before parsing: if (!isBalanced(input)) throw new IllegalArgumentException("unbalanced JSON"); Try / catch
try {
JsonReader.parse(json);
} catch (IllegalArgumentException e) {
if (e.getMessage().contains("ended without ]")) {
throw new ConfigException("Truncated JSON array in input; check for a missing ]", e);
}
throw e;
} Prevention
- Validate JSON with a standard parser before feeding custom readers
- Generate JSON via a serializer instead of string concatenation
- Verify generated files are fully written before consuming them
When it happens
Trigger: Passing a JSON string/document to the Quarkus build-step JSON reader where an array starts with '[' but the input ends (or a syntax error swallows the closing bracket) before ']' is encountered, e.g. "[1,2,3" or an element that consumed too many characters.
Common situations: Hand-written or templated JSON in build configuration that was cut off; build-step arguments serialized from a file that was truncated; copy-paste errors dropping the final ']' in JSON payloads passed to the builder; unescaped characters inside strings that hid the real ']' delimiter.
Related errors
- String not closed
- Unable to read json constant for: %s
- Control characters not allowed in json string
- Unable to fully read json value
- Unknown start character for json value: ${ch}
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/14af2c2e2c06c6ab.
Report an issue: GitHub.