Unity-Technologies/UnityCsReference · error · JSONParseException
missing '"' to end string at {}
Error message
missing '"' to end string at {} What it means
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.
Source
Thrown at Editor/Mono/AssetStore/Json.cs:524
}
}
Next();
return new JSONValue(dict);
}
static readonly char[] endcodes = { '\\', '"' };
private JSONValue ParseString()
{
string res = "";
Next();
while (idx < len)
{
int endidx = json.IndexOfAny(endcodes, idx);
if (endidx < 0)
throw new JSONParseException("missing '\"' to end string at " + PosMsg());
res += json.Substring(idx, endidx - idx);
if (json[endidx] == '"')
{
cur = json[endidx];
idx = endidx;
break;
}
endidx++; // get escape code
if (endidx >= len)
throw new JSONParseException("End of json while parsing while parsing string at " + PosMsg());
// char at endidx is \
char ncur = json[endidx];
switch (ncur)
{View on GitHub (pinned to 225b0fbdb5)
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.
Example fix
// before
// { "msg": "hello world }
// after
// { "msg": "hello world" } Defensive patterns
Strategy: validation
Validate before calling
if (string.IsNullOrEmpty(json)) throw new InvalidOperationException("empty JSON");
// For unterminated strings, verify completeness by reading to EOF before parsing. Try / catch
try { v = JSON.Parse(json); }
catch (JSONParseException ex) { /* position locates the unterminated string */ throw; } Prevention
- 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.
When it happens
Trigger: Truncated input cut mid-string; a literal string containing an unescaped quote that confused the structure; missing closing quote in hand-written JSON.
Common situations: Network truncation; copy/paste that dropped the trailing quote; embedding user text without escaping.
Related errors
- End of json while parsing while parsing string at {}
- End of json while parsing while parsing unicode char near {}
- End of json while parsing at {}
- Cannot parse json value starting with '{}' at {}
- Key not string type at {}
AI-assisted analysis of Unity-Technologies/UnityCsReference@225b0fbdb5 (2026-08-13).
Data as JSON: /api/errors/73fbae36c8df502c.
Report an issue: GitHub.