quarkusio/quarkus · error · IllegalArgumentException
Json object ended without }
Error message
Json object ended without }
What it means
While parsing a JSON object, readObject() consumes members inside '{' ... '}'. If the input is exhausted (end of text) before a closing '}' is found, the object is unbalanced and the reader throws IllegalArgumentException. It indicates a missing brace in the JSON document.
Source
Thrown at independent-projects/bootstrap/json/src/main/java/io/quarkus/bootstrap/json/JsonReader.java:109
Map<JsonString, JsonValue> members = new HashMap<>();
while (position < length) {
ignoreWhitespace();
switch (peekChar()) {
case '}':
position++;
return new JsonObject(members);
case ',':
position++;
break;
case '"':
readMember(members);
break;
}
}
throw new IllegalArgumentException("Json object ended without }");
}
/**
* member
* |----- ws string ws ':' element
*/
private void readMember(Map<JsonString, JsonValue> members) {
final JsonString attribute = readString();
ignoreWhitespace();
final int colon = nextChar();
if (':' != colon) {
throw new IllegalArgumentException("Expected : after attribute");
}
final JsonValue element = readElement();
members.put(attribute, element);
}
/**View on GitHub (pinned to e1c734241f)
Solutions
- Validate the JSON document and add the missing '}' at the position indicated by the parser
- If generating JSON by string concatenation, switch to a builder/serializer that guarantees balanced braces
- Check for truncation in the transport layer (file read limits, buffer sizes, HTTP body length)
Example fix
// before
String json = "{\"a\": 1";
// after
String json = "{\"a\": 1}"; Defensive patterns
Strategy: try-catch
Validate before calling
long opens = jsonText.chars().filter(c -> c == '{').count();
long closes = jsonText.chars().filter(c -> c == '}').count();
if (opens != closes) {
throw new IllegalArgumentException("Unbalanced braces in JSON input");
} Try / catch
try {
JsonValue v = new JsonReader(text).read();
} catch (IllegalArgumentException e) {
if (e.getMessage().equals("Json object ended without }")) {
// treat input as truncated/malformed: log and re-fetch or repair
}
} Prevention
- Prefer a JSON builder/serializer over string concatenation for generating JSON
- Validate generated JSON at the producer side before transport
- Watch for truncation in streaming or size-limited transports
When it happens
Trigger: A JSON object literal that is never closed, e.g. '{"a": 1' with no '}', or truncation in the middle of a nested object.
Common situations: Manually building JSON strings via string concatenation and missing the final brace; truncated network payloads; template-generated JSON with a conditionally dropped '}'.
Related errors
- Json array ended without ]
- Control characters not allowed in json string
- String not closed
- Unable to read json constant for: %s
- Unable to fully read json value
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/1cc45cfc5b2e6091.
Report an issue: GitHub.