{"record":{"id":"e8e713c6fb6f9739","repo":"ElectronNET/Electron.NET","slug":"unexpected-end-while-reading-object","errorCode":null,"errorMessage":"Unexpected end while reading object.","messagePattern":"Unexpected end while reading object\\.","errorType":"exception","errorClass":"JsonException","httpStatus":null,"severity":"error","filePath":"src/ElectronNET.API/Serialization/JsonToBoxedPrimitivesConverter.cs","lineNumber":43,"sourceCode":"                        {\n                            return obj;\n                        }\n\n                        if (r.TokenType != JsonTokenType.PropertyName)\n                        {\n                            throw new JsonException(\"Expected property name.\");\n                        }\n\n                        string name = r.GetString()!;\n                        if (!r.Read())\n                        {\n                            throw new JsonException(\"Unexpected end while reading property value.\");\n                        }\n\n                        obj[name] = ReadValue(ref r);\n                    }\n\n                    throw new JsonException(\"Unexpected end while reading object.\");\n\n                case JsonTokenType.StartArray:\n\n                    var list = new List<object>();\n                    while (r.Read())\n                    {\n                        if (r.TokenType == JsonTokenType.EndArray)\n                        {\n                            return list;\n                        }\n\n                        list.Add(ReadValue(ref r));\n                    }\n\n                    throw new JsonException(\"Unexpected end while reading array.\");\n\n                case JsonTokenType.True: return true;\n                case JsonTokenType.False: return false;","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/ElectronNET/Electron.NET/blob/87cc6f98b6a9c5968d7846c0e775ea713bd0d7b2/src/ElectronNET.API/Serialization/JsonToBoxedPrimitivesConverter.cs#L25-L61","documentation":"JsonToBoxedPrimitivesConverter.ReadValue throws this JsonException when it finishes consuming tokens without ever encountering the object's EndObject token — i.e. the JSON stream ended while still inside an object. It is the outer 'unexpected EOF inside object' guard, distinct from the per-property truncation errors.","triggerScenarios":"A JSON object missing its closing brace, e.g. '{ \"width\": 800 ' with no '}', or input stream ending mid-object while the reader loop runs out of tokens.","commonSituations":"Payloads cut off by IPC/network limits; incomplete file reads; string slicing bugs dropping the tail of the JSON.","solutions":["Ensure objects are closed with '}' — validate JSON before sending","Check transport (IPC/pipe) is not truncating messages","Log the raw received string on failure to find where it cuts off","Use JSON.stringify/JSON.parse round-trip on the sender to guarantee well-formed output"],"exampleFix":"// before\nvar json = \"{ \\\"width\\\": 800\"; // missing }\n// after\nvar json = \"{ \\\"width\\\": 800 }\";","handlingStrategy":"try-catch","validationCode":"bool isCompleteObject(string json) =>\n    json.TrimStart().StartsWith(\"{\") && json.TrimEnd().EndsWith(\"}\");","typeGuard":null,"tryCatchPattern":"try\n{\n    var value = JsonSerializer.Deserialize<object>(json, ElectronJson.Options);\n}\ncatch (JsonException ex)\n{\n    logger.LogWarning(ex, \"Incomplete JSON object: {Raw}\", json);\n}","preventionTips":["Use JSON.stringify for serialization to guarantee balanced braces","Log raw payloads on parse failure to spot truncation points","Increase transport limits for large payloads"],"tags":["json","parsing","truncated"],"backgroundTag":"json-parse-error","analyzedSha":"87cc6f98b6a9c5968d7846c0e775ea713bd0d7b2","analyzedAt":"2026-09-14T03:09:47.608Z","contentChangedAt":"2026-09-14T03:09:47.608Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}