{"record":{"id":"2fb941ad98b4373e","repo":"tui-cs/Terminal.Gui","slug":"propertyname-expected-a-string-value","errorCode":null,"errorMessage":"{propertyName}: Expected a string value.","messagePattern":"(.+?): Expected a string value\\.","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"Terminal.Gui/Configuration/AttributeJsonConverter.cs","lineNumber":84,"sourceCode":"                                  ? $\"\\\"{reader.GetString ()}\\\"\"\n                                  : $\"<{reader.TokenType}>\";\n\n            try\n            {\n                switch (propertyName?.ToLower ())\n                {\n                    case \"foreground\":\n                        foreground = JsonSerializer.Deserialize (ref reader, TuiSerializerContext.Instance.Color);\n\n                        break;\n                    case \"background\":\n                        background = JsonSerializer.Deserialize (ref reader, TuiSerializerContext.Instance.Color);\n\n                        break;\n                    case \"style\":\n                        if (reader.TokenType != JsonTokenType.String)\n                        {\n                            throw new JsonException ($\"{propertyName}: Expected a string value.\");\n                        }\n\n                        try\n                        {\n                            style = Enum.Parse<TextStyle> (reader.GetString ()!, ignoreCase: true);\n                        }\n                        catch (ArgumentException ex)\n                        {\n                            throw new JsonException (\"Expected a valid text style value.\", ex);\n                        }\n\n                        break;\n\n                    default:\n                        throw new JsonException ($\"{propertyName}: Unknown Attribute property .\");\n                }\n            }\n            catch (JsonException ex)","sourceCodeStart":66,"sourceCodeEnd":102,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/Configuration/AttributeJsonConverter.cs#L66-L102","documentation":"Thrown by AttributeJsonConverter.Read when the \"style\" property of an Attribute object is present but its JSON value is not a string token. TextStyle is parsed case-insensitively from a string, so a number, boolean, object, or array value is rejected here. The message names the offending propertyName.","triggerScenarios":"A config Attribute has \"Style\": 123, \"Style\": true, or \"Style\": { ... } instead of a string enum name like \"Bold\".","commonSituations":"Editor auto-completed a numeric value; config exported from a system that serializes enum-as-number (Terminal.Gui expects enum-as-string); misremembering TextStyle as a numeric flags value.","solutions":["Change the Style value to a TextStyle enum name string (case-insensitive), e.g. \"Bold\", \"Italic\", \"Underline\", \"None\", or a comma-joined combination the parser accepts.","If your exporter emits numbers, re-export with string enum serialization.","Validate with a JSON schema that types Style as string."],"exampleFix":"// before\n{ \"Foreground\": \"Red\", \"Background\": \"Black\", \"Style\": 1 }\n// after\n{ \"Foreground\": \"Red\", \"Background\": \"Black\", \"Style\": \"Bold\" }","handlingStrategy":"validation","validationCode":"// Ensure Style is a string token before deserializing.\nusing var doc = JsonDocument.Parse (jsonString);\nforeach (var attr in doc.RootElement.DescendantElements ().Where (e => e.TryGetProperty (\"Style\", out _)))\n{\n    if (attr.GetProperty (\"Style\").ValueKind != JsonValueKind.String)\n        throw new FormatException (\"Attribute.Style must be a string.\");\n}","typeGuard":null,"tryCatchPattern":"try { ConfigurationManager.Apply (); }\ncatch (JsonException ex) when (ex.Message.Contains (\"Expected a string value\"))\n{ /* fix the Style value in config */ }","preventionTips":["Always emit TextStyle as a string in generated config.","Document that Style is string-typed for anyone editing config by hand."],"tags":["configuration","json","theming","attribute","textstyle"],"backgroundTag":null,"analyzedSha":"2e47b11478db083499917f2ad27c34d30efb0df1","analyzedAt":"2026-08-13T19:20:08.826Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}