{"record":{"id":"f33dd7dd5ba88beb","repo":"hibernate/hibernate-orm","slug":"expected-json-object-end-but-none-found","errorCode":null,"errorMessage":"Expected JSON object end, but none found.","messagePattern":"Expected JSON object end, but none found\\.","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/JsonHelper.java","lineNumber":208,"sourceCode":"\t\t\t\t\t);\n\t\t\t\t\tcurrentSelectableData = null;\n\t\t\t\t}\n\t\t\t\tcase VALUE -> {\n\t\t\t\t\tfinal JdbcMapping jdbcMapping = currentLevel.determineJdbcMapping( currentSelectableData );\n\t\t\t\t\tcurrentLevel.addValue(\n\t\t\t\t\t\t\tcurrentSelectableData,\n\t\t\t\t\t\t\tadapter.fromValue(\n\t\t\t\t\t\t\t\t\tjdbcMapping.getJdbcJavaType(),\n\t\t\t\t\t\t\t\t\tjdbcMapping.getJdbcType(),\n\t\t\t\t\t\t\t\t\treader,\n\t\t\t\t\t\t\t\t\toptions\n\t\t\t\t\t\t\t)\n\t\t\t\t\t);\n\t\t\t\t\tcurrentSelectableData = null;\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t\tthrow new IllegalArgumentException( \"Expected JSON object end, but none found.\" );\n\t}\n\n\t/**\n\t * Deserialize a JSON value to Java Object\n\t * @param embeddableMappingType the mapping type\n\t * @param reader the JSON reader\n\t * @param returnEmbeddable do we return an Embeddable object or array of Objects\n\t * @param options wrappping options\n\t * @return the deserialized value\n\t */\n\tpublic static <X> X deserialize(\n\t\t\tEmbeddableMappingType embeddableMappingType,\n\t\t\tJsonDocumentReader reader,\n\t\t\tboolean returnEmbeddable,\n\t\t\tWrapperOptions options) throws SQLException {\n\t\tfinal JsonDocumentItemType event;\n\t\tif ( !reader.hasNext() || ( event = reader.next() ) == JsonDocumentItemType.NULL_VALUE ) {\n\t\t\treturn null;","sourceCodeStart":190,"sourceCodeEnd":226,"githubUrl":"https://github.com/hibernate/hibernate-orm/blob/fad1729dce015f908198d57a8d80274a30f905a5/hibernate-core/src/main/java/org/hibernate/type/descriptor/jdbc/JsonHelper.java#L190-L226","documentation":"JsonHelper.consumeJsonDocumentItems loops until the reader's OBJECT_END; if the reader is exhausted while still inside an object, it falls out of the loop and throws IllegalArgumentException('Expected JSON object end, but none found.') - the stored JSON is truncated or otherwise unterminated (missing '}').","triggerScenarios":"Reading a JSON-mapped embeddable whose column value is a truncated/unterminated object: a column too short for the document, a writer that truncated the string, or a document broken by manual editing.","commonSituations":"VARCHAR columns whose length silently truncates JSON on write (strict mode off); migration scripts that cut strings; hand-edited rows; buggy custom serialization writing partial documents.","solutions":["Repair the affected rows (rewrite valid JSON) and find the writer that produced truncated documents.","Enlarge the column (VARCHAR(n) bigger or use jsonb/json/TEXT types) so documents are never cut.","Ensure all writes go through the Hibernate mapping / a validating JsonFormatMapper."],"exampleFix":"-- before: column too short, writes truncated the document\nALTER TABLE product ALTER COLUMN attrs TYPE varchar(100); -- doc got cut\n-- load fails: Expected JSON object end, but none found.\n\n-- after: use a JSON-capable/longer column and repair rows\nALTER TABLE product ALTER COLUMN attrs TYPE jsonb;\nUPDATE product SET attrs = '{}' WHERE NOT attrs::text LIKE '%}';","handlingStrategy":"validation","validationCode":"// Before Hibernate reads it, confirm the column parses and closes its object\nstatic void assertWellFormed(String json) {\n    try {\n        new org.json.JSONObject(json); // throws on truncated/unterminated objects\n    } catch (Exception e) {\n        throw new IllegalArgumentException(\"Broken JSON in column: \" + json, e);\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    return session.find(Product.class, id);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Expected JSON object end\")) {\n        // truncated/unterminated object in the column: repair the row and enlarge the column\n    } else {\n        throw e;\n    }\n}","preventionTips":["Use native JSON column types (jsonb/json) or generous lengths for JSON data","Reject or log documents that fail strict parsing at write time","Never hand-edit JSON columns; script migrations with validated JSON"],"tags":["hibernate","json","malformed-data","truncation","aggregate-mapping"],"backgroundTag":"malformed-json-data","analyzedSha":"fad1729dce015f908198d57a8d80274a30f905a5","analyzedAt":"2026-08-22T04:13:57.527Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}