tui-cs/Terminal.Gui · error · JsonException
After {propertyName}: Invalid Json.
Error message
After {propertyName}: Invalid Json. What it means
The read loop exited (reader.Read returned false) without ever hitting an EndObject token — the JSON object for the Scheme was truncated or never closed. The converter falls through the while loop and throws.
Source
Thrown at Terminal.Gui/Configuration/SchemeJsonConverter.cs:79
"codenumber" => scheme with { CodeNumber = attribute },
"codeoperator" => scheme with { CodeOperator = attribute },
"codetype" => scheme with { CodeType = attribute },
"codepreprocessor" => scheme with { CodePreprocessor = attribute },
"codeidentifier" => scheme with { CodeIdentifier = attribute },
"codeconstant" => scheme with { CodeConstant = attribute },
"codepunctuation" => scheme with { CodePunctuation = attribute },
"codefunctionname" => scheme with { CodeFunctionName = attribute },
"codeattribute" => scheme with { CodeAttribute = attribute },
_ => throw new JsonException ($"{propertyName}: Unrecognized Scheme Attribute name.")
};
}
else
{
throw new JsonException ("null property name.");
}
}
throw new JsonException ($"After {propertyName}: Invalid Json.");
}
/// <inheritdoc/>
public override void Write (Utf8JsonWriter writer, Scheme value, JsonSerializerOptions options)
{
writer.WriteStartObject ();
foreach (VisualRole role in Enum.GetValues<VisualRole> ())
{
// Get the attribute for the role
if (!value.TryGetExplicitlySetAttributeForRole (role, out Attribute? attribute))
{
// Skip attributes that are not explicitly set
continue;
}
writer.WritePropertyName (role.ToString ());
// Write the attribute using the AttributeJsonConverterView on GitHub (pinned to 2e47b11478)
Solutions
- Add the missing closing brace(s) for the Scheme object.
- Validate the JSON is complete and balanced.
Example fix
// before
{ "Normal": { "Foreground": "White" }
// after
{ "Normal": { "Foreground": "White" } } Defensive patterns
Strategy: validation
Validate before calling
// Confirm the whole document is complete and balanced
try { using var doc = JsonDocument.Parse (File.ReadAllText (path)); }
catch (JsonException ex) { /* truncated; ex has byte position */ } Try / catch
try { ConfigurationManager.Apply (); }
catch (JsonException ex) when (ex.Message.Contains ("Invalid Json"))
{ /* likely a missing closing brace; ex.Message names last propertyName */ } Prevention
- Validate JSON completeness before loading.
- Use an editor that highlights unmatched braces.
When it happens
Trigger: A Scheme object missing its closing brace, e.g. { "Normal": {...} (no matching }), or a truncated file cut off mid-object.
Common situations: Truncated config file (disk full, copy-paste cut off); missing closing brace from hand-editing.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- After {propertyName}: Expected PropertyName but got another
- Unexpected StartObject token when parsing Scheme: {reader.To
- After {propertyName}: Expected Attribute but got {attrObj?.G
- {propertyName}: Unrecognized Scheme Attribute name.
- null property name.
AI-assisted analysis of tui-cs/Terminal.Gui@2e47b11478 (2026-08-13).
Data as JSON: /api/errors/23635e07bfce5820.
Report an issue: GitHub.