{"record":{"id":"d27222736a053e50","repo":"apache/seatunnel","slug":"json-parse-object-exception","errorCode":null,"errorMessage":"Json parse object exception!","messagePattern":"Json parse object exception!","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/JsonUtils.java","lineNumber":135,"sourceCode":"     * type information because of the Type Erasure feature of Java. Therefore, this method should\n     * not be used if the desired type is a generic type. Note that this method works fine if the\n     * any of the fields of the specified object are generics, just the object itself should not be\n     * a generic type.\n     *\n     * @param json the string from which the object is to be deserialized\n     * @param clazz the class of T\n     * @param <T> T\n     * @return an object of type T from the string classOfT\n     */\n    public static <T> T parseObject(String json, Class<T> clazz) {\n        if (StringUtils.isEmpty(json)) {\n            return null;\n        }\n\n        try {\n            return OBJECT_MAPPER.readValue(json, clazz);\n        } catch (Exception e) {\n            throw new RuntimeException(\"Json parse object exception!\", e);\n        }\n    }\n\n    /**\n     * json to list\n     *\n     * @param json json string\n     * @param clazz class\n     * @param <T> T\n     * @return list\n     */\n    public static <T> List<T> toList(String json, Class<T> clazz) {\n        if (StringUtils.isEmpty(json)) {\n            return Collections.emptyList();\n        }\n\n        try {\n            CollectionType listType =","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/JsonUtils.java#L117-L153","documentation":"JsonUtils.parseObject(String, Class<T>) deserializes a JSON string into an instance of the given class. If Jackson cannot parse the JSON or bind it to the target type, it rethrows as this RuntimeException with the original exception as cause.","triggerScenarios":"Calling JsonUtils.parseObject(json, clazz) with malformed JSON, a valid JSON scalar/array when an object is expected, or fields that do not match the target class's types (e.g. a string where an int is required).","commonSituations":"Parsing responses from external services that return HTML error pages instead of JSON, empty or truncated strings, passing a JSON array into parseObject for a bean, schema drift after upgrading the target class.","solutions":["Check the chained cause: JsonParseException means the input is not valid JSON; MismatchedInputException means shape/type mismatch","Validate/trim the input string; ensure it is non-empty and starts with '{' for object targets","If the payload is an array, use JsonUtils.toList or parseArray instead","Add missing @JsonIgnoreProperties(ignoreUnknown = true) or fix field types in the target class"],"exampleFix":"// before\nMyDto dto = JsonUtils.parseObject(arrayJsonText, MyDto.class); // input is a JSON array\n// after\nList<MyDto> list = JsonUtils.toList(arrayJsonText, MyDto.class);","handlingStrategy":"try-catch","validationCode":"boolean isJsonObject(String s) { return s != null && s.trim().startsWith(\"{\"); }","typeGuard":null,"tryCatchPattern":"try {\n    MyDto dto = JsonUtils.parseObject(json, MyDto.class);\n} catch (RuntimeException e) {\n    log.error(\"bad json payload: {}\", json, e.getCause());\n    throw new IllegalArgumentException(\"invalid json for MyDto\", e);\n}","preventionTips":["Check content-type/status of upstream responses before parsing","Annotate DTOs with @JsonIgnoreProperties(ignoreUnknown = true) to survive schema drift","Ensure the payload matches the target shape (object vs array) before choosing parseObject vs toList"],"tags":["jackson","deserialization","runtime-exception"],"backgroundTag":"json-unmarshal-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}