{"record":{"id":"41b29963784c1013","repo":"Unity-Technologies/UnityCsReference","slug":"invalid-token-at","errorCode":null,"errorMessage":"Invalid token at {}","messagePattern":"Invalid token at (.+?)","errorType":"exception","errorClass":"JSONParseException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/AssetStore/Json.cs","lineNumber":674,"sourceCode":"            c = \"\" + cur + Next() + Next() + Next();\n            Next();\n            if (c == \"true\")\n            {\n                return new JSONValue(true);\n            }\n            else if (c == \"fals\")\n            {\n                if (cur == 'e')\n                {\n                    Next();\n                    return new JSONValue(false);\n                }\n            }\n            else if (c == \"null\")\n            {\n                return new JSONValue(null);\n            }\n            throw new JSONParseException(\"Invalid token at \" + PosMsg());\n        }\n    }\n}\n","sourceCodeStart":656,"sourceCodeEnd":678,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/AssetStore/Json.cs#L656-L678","documentation":"Thrown by ParseConstant when a JSON literal token's four-character lookahead does not match 'true', 'fals' (prefix of 'false'), or 'null'. The parser reads four characters expecting a constant keyword; if none match, this error fires. It means the JSON contains an identifier-like token that is not a valid JSON keyword.","triggerScenarios":"Parsing JSON where a value position contains an unquoted token starting with a letter that is not true, false, or null — e.g. {\"flag\": True} (capital T), {\"x\": undefined}, {\"v\": NaN}. The parser consumed four characters and none matched any known constant.","commonSituations":"JavaScript-style boolean/null literals (True, False, Null, None) used instead of JSON-standard lowercase forms, language-agnostic data sources emitting non-JSON literals, corrupted or partially-garbled JSON, copy-paste from Python or YAML where True/None are capitalized.","solutions":["Check the JSON at the reported position for non-standard literal values (True instead of true, None instead of null, etc.).","Ensure the data producer serializes using a standard JSON library rather than manual string building.","If the source is under your control, replace capitalized or non-standard literals with lowercase JSON equivalents.","Sanitize the JSON by correcting known non-standard tokens before parsing."],"exampleFix":"// before — non-standard literal\nstring json = \"{\\\"enabled\\\": True, \\\"value\\\": None}\";\n// after — standard JSON literals\nstring json = \"{\\\"enabled\\\": true, \\\"value\\\": null}\";","handlingStrategy":"validation","validationCode":"// Pre-check that JSON literals are lowercase true/false/null\nusing System.Text.RegularExpressions;\nbool HasStandardLiterals(string json)\n{\n    // Flag non-standard capitalized or unrecognized literals in value positions\n    return !Regex.IsMatch(json, @\"(?<!\\w)(?:True|False|Null|None|Undefined|NaN|Infinity)(?!\\w)\");\n}","typeGuard":null,"tryCatchPattern":"try\n{\n    var result = JSONParser.SimpleParse(jsonString);\n}\ncatch (JSONParseException ex) when (ex.Message.Contains(\"Invalid token\"))\n{\n    Debug.LogError($\"Invalid JSON literal: {ex.Message}. Ensure true/false/null are lowercase.\");\n}","preventionTips":["Use a standard JSON serializer that always emits lowercase true/false/null.","When integrating data from Python/YAML sources, be aware of capitalized True/False/None.","Validate JSON with a linter that checks for non-standard literals.","Never substitute language-native boolean representations directly into JSON strings."],"tags":["json","parsing","asset-store","literal","malformed-data"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}