{"record":{"id":"d4a26ccfed91748a","repo":"tui-cs/Terminal.Gui","slug":"propertyname-expected-an-array-of-modifiers-bu","errorCode":null,"errorMessage":"{propertyName}: Expected an array of modifiers, but got \"{reader.TokenType}\".","messagePattern":"(.+?): Expected an array of modifiers, but got \"(.+?)\"\\.","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"Terminal.Gui/Configuration/KeyCodeJsonConverter.cs","lineNumber":102,"sourceCode":"                                    {\n                                        break;\n                                    }\n\n                                    string mod = reader.GetString ();\n\n                                    try\n                                    {\n                                        modifiers.Add (modifierDict [mod]);\n                                    }\n                                    catch (KeyNotFoundException e)\n                                    {\n                                        throw new JsonException ($\"{propertyName}: \\\"{mod}\\\" is not a valid modifier.\", e);\n                                    }\n                                }\n                            }\n                            else\n                            {\n                                throw new JsonException (\n                                                         $\"{propertyName}: Expected an array of modifiers, but got \\\"{reader.TokenType}\\\".\"\n                                                        );\n                            }\n\n                            break;\n\n                        default:\n                            throw new JsonException ($\"{propertyName}: Unexpected Key property.\");\n                    }\n                }\n            }\n\n            foreach (KeyCode modifier in modifiers)\n            {\n                key |= modifier;\n            }\n\n            return key;","sourceCodeStart":84,"sourceCodeEnd":120,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/Configuration/KeyCodeJsonConverter.cs#L84-L120","documentation":"Thrown by KeyCodeJsonConverter.Read (KeyCodeJsonConverter.cs:100-105) when the \"Modifiers\" property value is not a JSON StartArray token. Modifiers must be an array of strings ([\"Ctrl\", \"Shift\"]); providing a single string \"Ctrl\" or an object triggers this.","triggerScenarios":"Config JSON has \"Modifiers\": \"Ctrl\" (scalar string) or \"Modifiers\": { ... } instead of \"Modifiers\": [\"Ctrl\"].","commonSituations":"User writes a single modifier as a bare string for brevity. Tooling collapses single-element arrays to scalars. Copy-paste from a format that uses comma-separated strings.","solutions":["Always write Modifiers as a JSON array, even for a single modifier: [\"Ctrl\"].","For no modifiers, use an empty array [] or omit the Modifiers property.","Validate the Modifiers property is an array type before serializing config."],"exampleFix":"// before\n{ \"Key\": \"A\", \"Modifiers\": \"Ctrl\" }\n\n// after\n{ \"Key\": \"A\", \"Modifiers\": [\"Ctrl\"] }","handlingStrategy":"validation","validationCode":"using System.Text.Json;\n\nstatic bool ModifiersIsArray (string json, string propertyName)\n{\n    using JsonDocument doc = JsonDocument.Parse (json);\n    // locate the property; illustrative\n    return true;\n}\n\n// Ensure \"Modifiers\" is a JSON array in the raw config.","typeGuard":"static bool IsModifiersArray (JsonElement el) => el.ValueKind == JsonValueKind.Array;","tryCatchPattern":"try\n{\n    ConfigurationManager.Load (configJson);\n}\ncatch (JsonException ex) when (ex.Message.Contains (\"Expected an array of modifiers\"))\n{\n    // \"Modifiers\" was a scalar/object. Rewrite it as [\"...\"] and reload.\n}","preventionTips":["Always write Modifiers as a JSON array, even for a single modifier.","Use [] or omit Modifiers for no modifiers.","Validate the Modifiers property is an array before serializing.","Do not let tooling collapse single-element arrays to scalars."],"tags":["json","configuration","keybindings","key","modifiers","serialization"],"backgroundTag":null,"analyzedSha":"2e47b11478db083499917f2ad27c34d30efb0df1","analyzedAt":"2026-08-13T19:20:08.826Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}