{"record":{"id":"bcb498d4039ff92e","repo":"tui-cs/Terminal.Gui","slug":"unexpected-token-when-parsing-rune-reader-tokent","errorCode":null,"errorMessage":"Unexpected token when parsing Rune: {reader.TokenType}.","messagePattern":"Unexpected token when parsing Rune: (.+?)\\.","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"Terminal.Gui/Configuration/RuneJsonConverter.cs","lineNumber":135,"sourceCode":"                    }\n\n                    return new (combined [0]);\n                }\n            case JsonTokenType.Number:\n                {\n                    uint num = reader.GetUInt32 ();\n\n                    if (Rune.IsValid (num))\n                    {\n                        return new (num);\n                    }\n\n                    throw new JsonException ($\"{num}: Invalid Rune (not a scalar Unicode value).\");\n                }\n            case JsonTokenType.Null:\n                return default;\n            default:\n                throw new JsonException ($\"Unexpected token when parsing Rune: {reader.TokenType}.\");\n        }\n    }\n\n    public override void Write (Utf8JsonWriter writer, Rune value, JsonSerializerOptions options)\n    {\n        Rune printable = value.MakePrintable ();\n        if (printable == Rune.ReplacementChar)\n        {\n            // Write as /u string\n            writer.WriteRawValue ($\"\\\"{value}\\\"\");\n        }\n        else\n        {\n            // Write as the actual glyph\n            writer.WriteStringValue (value.ToString ());\n        }\n    }\n}","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/tui-cs/Terminal.Gui/blob/2e47b11478db083499917f2ad27c34d30efb0df1/Terminal.Gui/Configuration/RuneJsonConverter.cs#L117-L153","documentation":"The Rune converter received a JSON token that is neither String, Number, nor Null — e.g. True, False, StartArray, or StartObject. Rune only deserializes from those three token kinds; anything else hits the default switch arm.","triggerScenarios":"Config JSON has a boolean, array, or object where a Rune is expected, e.g. \"CheckMark\": true or \"CheckMark\": [97].","commonSituations":"YAML→JSON conversion artifacts; misunderstanding the Rune config format; a generator emitting wrong types.","solutions":["Provide the Rune as a string (\"a\", \"U+0061\", \"\\u0061\") or a decimal number (97).","Fix the upstream generator so it emits strings or numbers for Rune fields."],"exampleFix":"// before\n\"CheckMark\": true\n// after\n\"CheckMark\": \"U+2611\"","handlingStrategy":"validation","validationCode":"using var doc = JsonDocument.Parse (configText);\n// walk to each Rune-typed property and assert its ValueKind is String or Number\nbool ok = prop.Value.ValueKind is JsonValueKind.String or JsonValueKind.Number;","typeGuard":null,"tryCatchPattern":"try { ConfigurationManager.Apply (); }\ncatch (JsonException ex) when (ex.Message.Contains (\"Unexpected token when parsing Rune\"))\n{ /* report the token type from ex.Message */ }","preventionTips":["Validate the JSON schema for Rune-typed properties before loading.","Use ConfigurationManager's own serializer to round-trip-check generated config."],"tags":["config","json","rune","deserialization"],"backgroundTag":null,"analyzedSha":"2e47b11478db083499917f2ad27c34d30efb0df1","analyzedAt":"2026-08-13T19:20:08.826Z","schemaVersion":2},"datasetVersion":"2026-08-14T00:17:13.853Z"}