{"record":{"id":"1cc45cfc5b2e6091","repo":"quarkusio/quarkus","slug":"json-object-ended-without-1cc45c","errorCode":null,"errorMessage":"Json object ended without }","messagePattern":"Json object ended without \\}","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"independent-projects/bootstrap/json/src/main/java/io/quarkus/bootstrap/json/JsonReader.java","lineNumber":109,"sourceCode":"\n        Map<JsonString, JsonValue> members = new HashMap<>();\n\n        while (position < length) {\n            ignoreWhitespace();\n            switch (peekChar()) {\n                case '}':\n                    position++;\n                    return new JsonObject(members);\n                case ',':\n                    position++;\n                    break;\n                case '\"':\n                    readMember(members);\n                    break;\n            }\n        }\n\n        throw new IllegalArgumentException(\"Json object ended without }\");\n    }\n\n    /**\n     * member\n     * |----- ws string ws ':' element\n     */\n    private void readMember(Map<JsonString, JsonValue> members) {\n        final JsonString attribute = readString();\n        ignoreWhitespace();\n        final int colon = nextChar();\n        if (':' != colon) {\n            throw new IllegalArgumentException(\"Expected : after attribute\");\n        }\n        final JsonValue element = readElement();\n        members.put(attribute, element);\n    }\n\n    /**","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/independent-projects/bootstrap/json/src/main/java/io/quarkus/bootstrap/json/JsonReader.java#L91-L127","documentation":"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.","triggerScenarios":"A JSON object literal that is never closed, e.g. '{\"a\": 1' with no '}', or truncation in the middle of a nested object.","commonSituations":"Manually building JSON strings via string concatenation and missing the final brace; truncated network payloads; template-generated JSON with a conditionally dropped '}'.","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)"],"exampleFix":"// before\nString json = \"{\\\"a\\\": 1\";\n// after\nString json = \"{\\\"a\\\": 1}\";","handlingStrategy":"try-catch","validationCode":"long opens = jsonText.chars().filter(c -> c == '{').count();\nlong closes = jsonText.chars().filter(c -> c == '}').count();\nif (opens != closes) {\n    throw new IllegalArgumentException(\"Unbalanced braces in JSON input\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    JsonValue v = new JsonReader(text).read();\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().equals(\"Json object ended without }\")) {\n        // treat input as truncated/malformed: log and re-fetch or repair\n    }\n}","preventionTips":["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"],"tags":["json","parser","unbalanced-braces"],"backgroundTag":"malformed-json-input","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}