tui-cs/Terminal.Gui · error · JsonException
After {propertyName}: Expected a JSON property name, but got
Error message
After {propertyName}: Expected a JSON property name, but got "{reader.TokenType}" What it means
Inside a scope object (SettingsScope/ThemeScope), after reading a property value, the next token is not a PropertyName — malformed JSON such as a missing comma, a stray value, or wrong nesting. Mirrors the Scheme-level error 67 but at the Scope level.
Source
Thrown at Terminal.Gui/Configuration/ScopeJsonConverter.cs:50
{
if (reader.TokenType != JsonTokenType.StartObject)
{
throw new JsonException ($$"""Expected a JSON object ("{ "propName" : ... }"), but got "{{reader.TokenType}}".""");
}
var scope = (TScopeT)Activator.CreateInstance (typeof (TScopeT))!;
var propertyName = string.Empty;
while (reader.Read ())
{
if (reader.TokenType == JsonTokenType.EndObject)
{
return scope!;
}
if (reader.TokenType != JsonTokenType.PropertyName)
{
throw new JsonException ($"After {propertyName}: Expected a JSON property name, but got \"{reader.TokenType}\"");
}
propertyName = reader.GetString ();
reader.Read ();
// Get the hardcoded property from the TscopeT (e.g. ThemeScope.GetHardCodedProperty)
ConfigProperty? configProperty = scope.GetHardCodedProperty (propertyName!);
if (propertyName is { } && configProperty is { })
{
// This property name was found in the cached hard-coded scope dict.
// Add it, with no value
configProperty.HasValue = false;
configProperty.PropertyValue = null;
scope.TryAdd (propertyName, configProperty);
// Figure out if it needs a JsonConverter and if so, create oneView on GitHub (pinned to 2e47b11478)
Solutions
- Run the config through a JSON linter.
- Fix missing commas / nesting; ensure flat key:value pairs separated by commas.
Example fix
// before
{ "Schemes": {...} "Themes": {...} }
// after
{ "Schemes": {...}, "Themes": {...} } Defensive patterns
Strategy: validation
Validate before calling
// Pre-validate JSON syntax
try { JsonDocument.Parse (File.ReadAllText (path)); }
catch (JsonException ex) { /* missing comma / bad nesting; ex has position */ } Try / catch
try { ConfigurationManager.Apply (); }
catch (JsonException ex) when (ex.Message.Contains ("Expected a JSON property name"))
{ /* ex.Message names the last propertyName before the error */ } Prevention
- Lint JSON before loading.
- Use a JSON-aware editor that flags malformed syntax.
When it happens
Trigger: A scope object with missing commas, stray tokens, or mis-nested values, e.g. { "Schemes": {...} "Themes": {...} }.
Common situations: Hand-editing config and dropping commas; a templating tool emitting malformed JSON.
Related errors
- Expected a JSON object ("{ "propName" : ... }"), but got "{r
- After {propertyName}: Expected PropertyName but got another
- After {propertyName}: Invalid Json.
- {propertyName}: Unknown property name.
- Unexpected StartObject token when parsing Attribute: {reader
AI-assisted analysis of tui-cs/Terminal.Gui@2e47b11478 (2026-08-13).
Data as JSON: /api/errors/2246a2f69c861d56.
Report an issue: GitHub.