{"record":{"id":"7c5a1422fc1cb7d3","repo":"json-path/JsonPath","slug":"unknown-value-type-value-getvaluetype","errorCode":null,"errorMessage":"Unknown value type \" + value.getValueType()","messagePattern":"Unknown value type \" \\+ value\\.getValueType\\(\\)","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"json-path/src/main/java/com/jayway/jsonpath/spi/mapper/JakartaMappingProvider.java","lineNumber":565,"sourceCode":"\r\n        private Event getState(JsonValue value) {\r\n            switch (value.getValueType()) {\r\n            case ARRAY:\r\n                return Event.START_ARRAY;\r\n            case OBJECT:\r\n                return Event.START_OBJECT;\r\n            case STRING:\r\n                return Event.VALUE_STRING;\r\n            case NUMBER:\r\n                return Event.VALUE_NUMBER;\r\n            case TRUE:\r\n                return Event.VALUE_TRUE;\r\n            case FALSE:\r\n                return Event.VALUE_FALSE;\r\n            case NULL:\r\n                return Event.VALUE_NULL;\r\n            default:\r\n                throw new JsonException(\"Unknown value type \" + value.getValueType());\r\n            }\r\n        }\r\n    }\r\n\r\n    private static abstract class JsonStructureScope implements Iterator<JsonValue> {\r\n        /**\r\n         * Returns current {@link JsonValue}, that the parser is pointing on. Before\r\n         * the {@link #next()} method has been called, this returns {@code null}.\r\n         *\r\n         * @return JsonValue value object.\r\n         */\r\n        abstract JsonValue getValue();\r\n    }\r\n\r\n    private static class JsonArrayScope extends JsonStructureScope {\r\n        private final Iterator<JsonValue> it;\r\n        private JsonValue value;\r\n\r","sourceCodeStart":547,"sourceCodeEnd":583,"githubUrl":"https://github.com/json-path/JsonPath/blob/62a4c9f0f65ba3f625aa0867d64c528ba72d09ec/json-path/src/main/java/com/jayway/jsonpath/spi/mapper/JakartaMappingProvider.java#L547-L583","documentation":"getState() maps a JsonValue's type to a parser Event; ARRAY, OBJECT, STRING, NUMBER, TRUE, FALSE, and NULL are handled, and any other ValueType falls into the default branch throwing this JsonException. With the standard JSON-P enum this is effectively unreachable, but it guards against exotic or future JsonValue implementations.","triggerScenarios":"Passing a JsonValue whose getValueType() is not one of the seven standard JSON-P types — e.g. a custom or third-party JsonValue implementation with its own ValueType, or a value from a non-standard JSON-P version.","commonSituations":"Custom JsonValue implementations injected into the mapping pipeline; mixing JSON-P implementations (different providers on the classpath producing foreign JsonValue instances).","solutions":["Ensure all JsonValue instances come from the same JSON-P provider (check for multiple jsonp implementations on the classpath)","Convert foreign/custom JsonValue wrappers into standard JsonObject/JsonArray before mapping","Catch JsonException and inspect value.getValueType() to identify the offending implementation"],"exampleFix":"// before\nJsonValue v = customLib.toJsonValue(data); // non-standard ValueType\nadapter.next(); // JsonException: Unknown value type\n// after\nJsonValue v = Json.createObjectBuilder() // standard JSON-P API\n    .add(\"data\", customLib.toJsonString(data)).build();","handlingStrategy":"validation","validationCode":"switch (value.getValueType()) {\n    case ARRAY: case OBJECT: case STRING: case NUMBER:\n    case TRUE: case FALSE: case NULL: break;\n    default: throw new IllegalStateException(\"Non-standard JsonValue type: \" + value.getValueType());\n}","typeGuard":"boolean isStandardJsonValue(JsonValue v) {\n    switch (v.getValueType()) {\n        case ARRAY: case OBJECT: case STRING: case NUMBER:\n        case TRUE: case FALSE: case NULL: return true;\n        default: return false;\n    }\n}","tryCatchPattern":"try {\n    mapper.map(value, typeRef, config);\n} catch (JsonException e) {\n    // unknown ValueType: value likely from a foreign JSON-P implementation\n}","preventionTips":["Keep a single JSON-P implementation on the classpath; check for duplicate jsonp jars","Convert custom/third-party JsonValue wrappers to standard JsonObject/JsonArray before mapping","Pin JSON-P provider versions in your build"],"tags":["json","json-path","json-p","internal-invariant"],"backgroundTag":"internal-invariant-violation","analyzedSha":"62a4c9f0f65ba3f625aa0867d64c528ba72d09ec","analyzedAt":"2026-09-11T11:36:00.448Z","contentChangedAt":"2026-09-11T11:36:00.448Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}