{"record":{"id":"5088d885b56849f7","repo":"apache/seatunnel","slug":"json-parse-object-exception-5088d8","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":249,"sourceCode":"    }\n\n    /**\n     * json to object\n     *\n     * @param json json string\n     * @param type type reference\n     * @param <T> type\n     * @return return parse object\n     */\n    public static <T> T parseObject(String json, TypeReference<T> type) {\n        if (StringUtils.isEmpty(json)) {\n            return null;\n        }\n\n        try {\n            return OBJECT_MAPPER.readValue(json, type);\n        } catch (Exception e) {\n            throw new RuntimeException(\"Json parse object exception.\", e);\n        }\n    }\n\n    /**\n     * object to json string\n     *\n     * @param object object\n     * @return json string\n     */\n    public static String toJsonString(Object object) {\n        try {\n            return OBJECT_MAPPER.writeValueAsString(object);\n        } catch (Exception e) {\n            throw new RuntimeException(\"Object json deserialization exception.\", e);\n        }\n    }\n\n    public static ObjectNode parseObject(String text) {","sourceCodeStart":231,"sourceCodeEnd":267,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-common/src/main/java/org/apache/seatunnel/common/utils/JsonUtils.java#L231-L267","documentation":"JsonUtils.parseObject(String, JavaType/TypeReference) is the generic-typed variant of parseObject that binds JSON to an arbitrary Jackson type. Failures are wrapped in this RuntimeException (note the trailing period distinguishing it from error 172).","triggerScenarios":"Calling JsonUtils.parseObject(json, type) where json is malformed, or cannot be bound to the supplied JavaType/TypeReference (wrong nesting, incompatible field types).","commonSituations":"Parsing deeply generic payloads (Map<String,List<Foo>>) built with TypeReference, API responses that changed shape, key/value type erasure mistakes when constructing the JavaType.","solutions":["Check the chained cause to distinguish syntax errors from binding errors","Verify the JavaType/TypeReference matches the actual JSON shape including generics","If the JSON is a plain array/scalar, use toList or parseArray instead","Log the offending JSON (truncate if large) alongside the exception to debug"],"exampleFix":"// before\nMap<String, List<Integer>> r = JsonUtils.parseObject(json, new TypeReference<Map<String, List<String>>>() {}); // wrong value type\n// after\nMap<String, List<Integer>> r = JsonUtils.parseObject(json, new TypeReference<Map<String, List<Integer>>>() {});","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    Result r = JsonUtils.parseObject(json, new TypeReference<Result>() {});\n} catch (RuntimeException e) {\n    log.error(\"typed parse failed, cause={}\", e.getCause());\n    throw new IllegalArgumentException(\"json does not match expected type\", e);\n}","preventionTips":["Double-check TypeReference generics match the real JSON structure","Log the raw payload (truncated) when typed parsing fails","Pin the JSON schema of external APIs and test against samples on upgrades"],"tags":["jackson","deserialization","generics"],"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"}