{"record":{"id":"69793d3676c7c2ff","repo":"json-path/JsonPath","slug":"e","errorCode":null,"errorMessage":"e","messagePattern":"e","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"json-path/src/main/java/com/jayway/jsonpath/internal/filter/ValueNodes.java","lineNumber":148,"sourceCode":"        }\n\n        public JsonNode asJsonNode() {\n            return this;\n        }\n\n        public ValueNode asValueListNode(Predicate.PredicateContext ctx){\n            if(!isArray(ctx)){\n                return UNDEFINED;\n            } else {\n                return new ValueListNode(Collections.unmodifiableList((List) parse(ctx)));\n            }\n        }\n\n        public Object parse(Predicate.PredicateContext ctx){\n            try {\n              return parsed ? json : new JSONParser(JSONParser.MODE_PERMISSIVE).parse(json.toString());\n            } catch (ParseException e) {\n              throw new IllegalArgumentException(e);\n            }\n        }\n\n        public boolean isParsed() {\n            return parsed;\n        }\n\n        public Object getJson() {\n            return json;\n        }\n\n        public boolean isArray(Predicate.PredicateContext ctx) {\n            return parse(ctx) instanceof List;\n        }\n\n        public boolean isMap(Predicate.PredicateContext ctx) {\n            return parse(ctx) instanceof Map;\n        }","sourceCodeStart":130,"sourceCodeEnd":166,"githubUrl":"https://github.com/json-path/JsonPath/blob/62a4c9f0f65ba3f625aa0867d64c528ba72d09ec/json-path/src/main/java/com/jayway/jsonpath/internal/filter/ValueNodes.java#L130-L166","documentation":"ValueNode.parse() evaluates an inline JSON literal used as an operand in a filter expression. It uses JSONParser in MODE_PERMISSIVE to parse the raw text; if parsing fails (ParseException), it wraps it in an IllegalArgumentException. This means the JSON literal embedded in the path/filter expression is malformed, so JsonPath cannot turn it into a value for comparison.","triggerScenarios":"A filter like [?(@.foo == <literal>)] where <literal> is text the permissive parser still rejects — e.g. unbalanced braces/brackets, invalid escape sequences, or malformed JSON fragments inside the path string — is passed to JsonPath.parse()/read(). parse() is invoked by type(), asValueListNode(), isArray(), isMap(), length(), isEmpty() when the operand node is first evaluated.","commonSituations":"Hand-written path strings with typos in embedded JSON (e.g. [?(@.x in {'a','b']) single quotes/braces mixups), dynamically concatenated path strings from user input, or copying JSON literals with trailing commas into a predicate.","solutions":["Validate/fix the JSON literal embedded in the filter expression; quote strings properly ('value' or \"value\").","Print/log the full path string before calling JsonPath.read() and check the literal fragment manually with a JSON linter.","Use JsonPath's predicate API (Filter.filter(where(...))) instead of string-embedded literals to avoid parsing text.","Catch IllegalArgumentException from read() to surface a user-facing invalid-path message."],"exampleFix":"// before\nList<Map<String,Object>> r = JsonPath.read(json, \"$[?(@.x in {a,b})]\"); // malformed literal\n// after\nList<Map<String,Object>> r = JsonPath.read(json, \"$[?(@.x in ['a','b'])]\");","handlingStrategy":"validation","validationCode":"if (!path.matches(\".*\\\\[\\\\?\\\\(.*['\\\"]?[^'\\\"]*['\\\"]?.*\\\\)\\\\]\")) throw new IllegalArgumentException(\"Suspicious literal in filter: \" + path);\n// or: assert the embedded literal parses: try { new JSONParser(JSONParser.MODE_PERMISSIVE).parse(literal); } catch (ParseException e) { throw new IllegalArgumentException(e); }","typeGuard":null,"tryCatchPattern":"try {\n    JsonPath.read(json, path);\n} catch (IllegalArgumentException e) {\n    throw new InvalidPathException(\"Malformed literal in path: \" + path, e);\n}","preventionTips":["Quote all string literals in filters with single quotes","Lint generated path strings before use","Prefer the Filter.where(...) predicate API over string filters"],"tags":["json","path-expression","parsing"],"backgroundTag":"json-parse-error","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"}