{"record":{"id":"bc6f5577cfca932b","repo":"json-path/JsonPath","slug":"character-on-position-is-not-valid","errorCode":null,"errorMessage":"Character '.' on position  is not valid.","messagePattern":"Character '\\.' on position  is not valid\\.","errorType":"exception","errorClass":"InvalidPathException","httpStatus":null,"severity":"error","filePath":"json-path/src/main/java/com/jayway/jsonpath/internal/path/PathCompiler.java","lineNumber":173,"sourceCode":"                }\n                return true;\n        }\n    }\n\n    //\n    // . and ..\n    //\n    private boolean readDotToken(PathTokenAppender appender) {\n        if (path.currentCharIs(PERIOD) && path.nextCharIs(PERIOD)) {\n            appender.appendPathToken(PathTokenFactory.crateScanToken());\n            path.incrementPosition(2);\n        } else if (!path.hasMoreCharacters()) {\n            throw new InvalidPathException(\"Path must not end with a '.\");\n        } else {\n            path.incrementPosition(1);\n        }\n        if(path.currentCharIs(PERIOD)){\n            throw new InvalidPathException(\"Character '.' on position \" + path.position() + \" is not valid.\");\n        }\n        return readNextToken(appender);\n    }\n\n    //\n    // fooBar or fooBar()\n    //\n    private boolean readPropertyOrFunctionToken(PathTokenAppender appender) {\n        if (path.currentCharIs(OPEN_SQUARE_BRACKET) || path.currentCharIs(WILDCARD) || path.currentCharIs(PERIOD) || path.currentCharIs(SPACE)) {\n            return false;\n        }\n        int startPosition = path.position();\n        int readPosition = startPosition;\n        int endPosition = 0;\n\n        boolean isFunction = false;\n\n        while (path.inBounds(readPosition)) {","sourceCodeStart":155,"sourceCodeEnd":191,"githubUrl":"https://github.com/json-path/JsonPath/blob/62a4c9f0f65ba3f625aa0867d64c528ba72d09ec/json-path/src/main/java/com/jayway/jsonpath/internal/path/PathCompiler.java#L155-L191","documentation":"After consuming a dot token, readDotToken checks whether the current character is another '.': a second consecutive dot where a property is expected (not part of the two-character '..' scan operator) is invalid, so compilation throws InvalidPathException reporting the offending position.","triggerScenarios":"Paths like `$.a..b` are valid (scan), but `$.a...b`, `$..b.` followed by another dot, or `$.a..` (dot after scan at end via different branch) produce a lone '.' in property position.","commonSituations":"Typos with too many dots; template string concatenation adding an extra separator before a dynamic segment; confusion between scan `..` and deep-property attempts.","solutions":["Fix the extra '.' in the path — use exactly two dots for a scan (`$..price`) and one for property access (`$.price`).","Sanitize programmatically built paths by collapsing runs of 3+ dots: `path.replace(\"...\", \"..\")` only if a scan was intended; otherwise remove extras.","Compile paths in a try-catch during development to catch bad separators early."],"exampleFix":"// before\nJsonPath.read(json, \"$..store...price\"); // triple dot\n// after\nJsonPath.read(json, \"$..store..price\"); // or $.store.price","handlingStrategy":"validation","validationCode":"String normalizeDots(String p) {\n    return p == null ? null : p.replaceAll(\"\\\\.{3,}\", \"..\"); // keep at most scan '..'\n}","typeGuard":null,"tryCatchPattern":"try {\n    return JsonPath.read(json, path);\n} catch (InvalidPathException e) {\n    throw new IllegalArgumentException(\"Invalid dot usage in path: \" + path, e);\n}","preventionTips":["Use '..' only for scans and '.' for property access — never three dots.","Review templated paths that interpolate segments with separators.","Add a compile-time smoke test for every path constant."],"tags":["json-path","invalid-path","syntax","compiler"],"backgroundTag":"invalid-path-syntax","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"}