{"record":{"id":"65712d14bd0dd369","repo":"JamesNK/Newtonsoft.Json","slug":"unexpected-character-while-parsing-path-indexer","errorCode":null,"errorMessage":"Unexpected character while parsing path indexer: ","messagePattern":"Unexpected character while parsing path indexer: ","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"Src/Newtonsoft.Json/Linq/JsonPath/JPath.cs","lineNumber":333,"sourceCode":"                    string indexer = _expression.Substring(start, length);\n                    indexes.Add(Convert.ToInt32(indexer, CultureInfo.InvariantCulture));\n\n                    _currentIndex++;\n\n                    EatWhitespace();\n\n                    start = _currentIndex;\n                    end = null;\n                }\n                else if (currentCharacter == '*')\n                {\n                    _currentIndex++;\n                    EnsureLength(\"Path ended with open indexer.\");\n                    EatWhitespace();\n\n                    if (_expression[_currentIndex] != indexerCloseChar)\n                    {\n                        throw new JsonException(\"Unexpected character while parsing path indexer: \" + currentCharacter);\n                    }\n\n                    return new ArrayIndexFilter();\n                }\n                else if (currentCharacter == ':')\n                {\n                    int length = (end ?? _currentIndex) - start;\n\n                    if (length > 0)\n                    {\n                        string indexer = _expression.Substring(start, length);\n                        int index = Convert.ToInt32(indexer, CultureInfo.InvariantCulture);\n\n                        if (colonCount == 0)\n                        {\n                            startIndex = index;\n                        }\n                        else if (colonCount == 1)","sourceCodeStart":315,"sourceCodeEnd":351,"githubUrl":"https://github.com/JamesNK/Newtonsoft.Json/blob/4f73e74372445108d2c1bda37b36e6f5e43402e0/Src/Newtonsoft.Json/Linq/JsonPath/JPath.cs#L315-L351","documentation":"Thrown by the JPath array-indexer parser when a wildcard '*' is followed by a character other than the indexer's closing bracket. After consuming '*' and whitespace, the parser expects ']' (or ')'); anything else (JPath.cs:331-333) is rejected.","triggerScenarios":"A path like token.SelectToken(\"$[*1]\") or \"$[*,0]\" where '*' is not immediately followed by the closing ']'. The parser advances past '*' then finds an unexpected character.","commonSituations":"Mixing wildcard and explicit index syntax; typos where '*' is meant as multiplication or a glob; concatenation placing extra content inside a wildcard indexer.","solutions":["Use '[*]' alone for a wildcard, or '[0]' for a specific index, never both in one indexer.","Remove any trailing characters after '*' inside the brackets.","If you need multiple indices, use a comma list of integers: $[0,1]."],"exampleFix":"// before\ntoken.SelectToken(\"$[*1]\");\n\n// after\ntoken.SelectToken(\"$[*]\");","handlingStrategy":"validation","validationCode":"// Use '*' only as a standalone wildcard, never mixed with indices\nstring indexer = wantAll ? \"[*]\" : $\"[{index}]\";\nstring path = $\"$.data{indexer}\";","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use '[*]' alone or '[0]' alone, never a mix like '[*1]'.","If you need multiple indices, use a comma list of integers.","Treat '*' as an exclusive choice within a single indexer."],"tags":["jsonpath","parse-error","array-indexer"],"analyzedSha":"4f73e74372445108d2c1bda37b36e6f5e43402e0","analyzedAt":"2026-08-07T06:10:08.596Z","schemaVersion":2},"datasetVersion":"2026-08-07T07:17:06.508Z"}