{"record":{"id":"73fbae36c8df502c","repo":"Unity-Technologies/UnityCsReference","slug":"missing-to-end-string-at","errorCode":null,"errorMessage":"missing '\"' to end string at {}","messagePattern":"missing '\"' to end string at (.+?)","errorType":"exception","errorClass":"JSONParseException","httpStatus":null,"severity":"error","filePath":"Editor/Mono/AssetStore/Json.cs","lineNumber":524,"sourceCode":"                }\n            }\n            Next();\n            return new JSONValue(dict);\n        }\n\n        static readonly char[] endcodes = { '\\\\', '\"' };\n\n        private JSONValue ParseString()\n        {\n            string res = \"\";\n\n            Next();\n\n            while (idx < len)\n            {\n                int endidx = json.IndexOfAny(endcodes, idx);\n                if (endidx < 0)\n                    throw new JSONParseException(\"missing '\\\"' to end string at \" + PosMsg());\n\n                res += json.Substring(idx, endidx - idx);\n\n                if (json[endidx] == '\"')\n                {\n                    cur = json[endidx];\n                    idx = endidx;\n                    break;\n                }\n\n                endidx++; // get escape code\n                if (endidx >= len)\n                    throw new JSONParseException(\"End of json while parsing while parsing string at \" + PosMsg());\n\n                // char at endidx is \\\n                char ncur = json[endidx];\n                switch (ncur)\n                {","sourceCodeStart":506,"sourceCodeEnd":542,"githubUrl":"https://github.com/Unity-Technologies/UnityCsReference/blob/225b0fbdb57cc17d094e8056b71f8314aba56f73/Editor/Mono/AssetStore/Json.cs#L506-L542","documentation":"ParseString scans for the next '\"' or '\\' via IndexOfAny; if neither is found before end of input, it throws JSONParseException (\"missing '\"' to end string at <pos>\"). This is the unterminated-string signal: the opening quote was seen but no closing quote (and no escape) followed within the buffer.","triggerScenarios":"Truncated input cut mid-string; a literal string containing an unescaped quote that confused the structure; missing closing quote in hand-written JSON.","commonSituations":"Network truncation; copy/paste that dropped the trailing quote; embedding user text without escaping.","solutions":["Verify the input is complete (read to EOF / match Content-Length) before parsing.","Ensure all string literals are properly terminated and quotes inside are escaped (\\\").","Catch JSONParseException and report the position for repair."],"exampleFix":"// before\n// { \"msg\": \"hello world }\n\n// after\n// { \"msg\": \"hello world\" }","handlingStrategy":"validation","validationCode":"if (string.IsNullOrEmpty(json)) throw new InvalidOperationException(\"empty JSON\");\n// For unterminated strings, verify completeness by reading to EOF before parsing.","typeGuard":null,"tryCatchPattern":"try { v = JSON.Parse(json); }\ncatch (JSONParseException ex) { /* position locates the unterminated string */ throw; }","preventionTips":["Confirm input completeness (match Content-Length / read to EOF) before parsing.","Escape embedded quotes (\\\") when embedding user text into JSON.","Use a serializer to guarantee well-formed strings."],"tags":["json","parse","truncated-input","string-escape","asset-store","unity"],"backgroundTag":null,"analyzedSha":"225b0fbdb57cc17d094e8056b71f8314aba56f73","analyzedAt":"2026-08-13T19:07:19.849Z","schemaVersion":2},"datasetVersion":"2026-08-13T19:17:28.613Z"}