{"record":{"id":"5d7d2ec27ec51789","repo":"json-path/JsonPath","slug":"could-not-determine-value-type","errorCode":null,"errorMessage":"Could not determine value type","messagePattern":"Could not determine value type","errorType":"exception","errorClass":"JsonPathException","httpStatus":null,"severity":"error","filePath":"json-path/src/main/java/com/jayway/jsonpath/internal/filter/ValueNode.java","lineNumber":178,"sourceCode":"    //----------------------------------------------------\n    //\n    // Factory methods\n    //\n    //----------------------------------------------------\n    public static ValueNode toValueNode(Object o){\n\n        if(o == null) return NULL_NODE;\n        if(o instanceof ValueNode) return (ValueNode)o;\n        if(o instanceof Class) return createClassNode((Class)o);\n        else if(isPath(o)) return new PathNode(o.toString(), false, false);\n        else if(isJson(o)) return createJsonNode(o.toString());\n        else if(o instanceof String) return createStringNode(o.toString(), true);\n        else if(o instanceof Character) return createStringNode(o.toString(), false);\n        else if(o instanceof Number) return createNumberNode(o.toString());\n        else if(o instanceof Boolean) return createBooleanNode(o.toString());\n        else if(o instanceof Pattern) return createPatternNode((Pattern)o);\n        else if (o instanceof OffsetDateTime) return createOffsetDateTimeNode(o.toString());  //workaround for issue: https://github.com/json-path/JsonPath/issues/613\n        else throw new JsonPathException(\"Could not determine value type\");\n\n    }\n\n    public static StringNode createStringNode(CharSequence charSequence, boolean escape){\n        return new StringNode(charSequence, escape);\n    }\n\n    public static ClassNode createClassNode(Class<?> clazz){\n        return new ClassNode(clazz);\n    }\n\n    public static NumberNode createNumberNode(CharSequence charSequence){\n        return new NumberNode(charSequence);\n    }\n\n    public static BooleanNode createBooleanNode(CharSequence charSequence){\n        return Boolean.parseBoolean(charSequence.toString()) ? TRUE : FALSE;\n    }","sourceCodeStart":160,"sourceCodeEnd":196,"githubUrl":"https://github.com/json-path/JsonPath/blob/62a4c9f0f65ba3f625aa0867d64c528ba72d09ec/json-path/src/main/java/com/jayway/jsonpath/internal/filter/ValueNode.java#L160-L196","documentation":"ValueNode.toValueNode(Object o) converts an arbitrary Java object into a ValueNode for filter evaluation (strings, characters, numbers, booleans, Patterns, OffsetDateTimes are supported). When the object's type is unrecognized, it throws JsonPathException(\"Could not determine value type\"). This happens when a filter operand or evaluated value is a Java type the converter does not handle, such as Map, List, raw Date, UUID, byte[], or custom POJOs.","triggerScenarios":"Passing an unsupported Java object as a filter operand or as a document value that needs conversion: e.g. supplying a java.util.Date or java.util.UUID in a filter parameter, a List/Map not converted by the caller, or a custom type reaching toValueNode during evaluation of a parameterized filter like $.items[?(@.x in ${list})].","commonSituations":"Using java.util.Date instead of OffsetDateTime for date filters (pre-#613 types unsupported); passing Java 8+ types like UUID or enums; supplying collections that should have been pre-parsed via JsonPath.parse; custom JSON providers producing wrapper objects that leak into toValueNode.","solutions":["Convert the value to a supported type before evaluation: OffsetDateTime for dates, String/Number/Boolean/Pattern/Character","Convert Maps and Lists to a parsed document via JsonPath.parse()/Configuration before using them as operands","Use the #613 workaround contract: pass OffsetDateTime (not java.util.Date) for datetime comparisons","Catch JsonPathException around evaluation and implement custom conversion logic for your types"],"exampleFix":"// before\nDate d = new Date();\nfilter.where(\"$.created lt \" + d); // java.util.Date -> JsonPathException\n// after\nOffsetDateTime d = OffsetDateTime.now();\nfilter.where(\"$.created lt \" + d); // supported type","handlingStrategy":"validation","validationCode":"static void assertSupportedOperand(Object o) {\n    if (!(o instanceof String || o instanceof Character || o instanceof Number || o instanceof Boolean || o instanceof Pattern || o instanceof OffsetDateTime))\n        throw new IllegalArgumentException(\"Unsupported filter operand type: \" + o.getClass());\n}","typeGuard":"static boolean isConvertibleToValueNode(Object o) { return o instanceof String || o instanceof Character || o instanceof Number || o instanceof Boolean || o instanceof Pattern || o instanceof OffsetDateTime; }","tryCatchPattern":"try {\n    return JsonPath.parse(json).read(\"$.items[?(@.x in [\" + operand + \"])]\");\n} catch (JsonPathException e) {\n    if (e.getMessage().contains(\"Could not determine value type\")) {\n        // convert the operand to a supported type and retry\n        return evaluateWithConvertedOperand(json);\n    }\n    throw e;\n}","preventionTips":["Pass only String/Character/Number/Boolean/Pattern/OffsetDateTime as filter operands","Convert java.util.Date to OffsetDateTime before filtering","Parse Maps/Lists into documents with JsonPath.parse before using them as operands","Convert UUID/enums/custom types to String before embedding in filters"],"tags":["jsonpath","filter","unsupported-type","conversion"],"backgroundTag":"unsupported-operation","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"}