qishibo/AnotherRedisDesktopManager · error
this.$t('message.json_format_failed')
Error message
this.$t('message.json_format_failed') What it means
Localized Element UI toast (message.json_format_failed) shown when JSON.parse() throws while re-encoding protobuf content. The viewer editor works on the JSON representation produced by protobufjs Message.toJSON(); on save, getContent() must parse the edited JSON text back before type.fromObject() converts it into a typed message. Any syntax error in the edited JSON aborts with this message.
Source
Thrown at src/components/viewers/ViewerProtobuf.vue:109
methods: {
getContent() {
if (!this.protoRoot) {
this.$message.error('Select a correct .proto file');
return false;
}
if (!this.selectedType || this.selectedType === 'Rawproto') {
this.$message.error('Select a correct Type to encode');
return false;
}
let content = this.$refs.editor.getRawContent();
const type = this.protoRoot.lookupType(this.selectedType);
try {
content = JSON.parse(content);
} catch (e) {
this.$message.error(this.$t('message.json_format_failed'));
return false;
}
// toJSON() shows int64/uint64 as strings; fromObject converts them back
const message = type.fromObject(content);
const err = type.verify(message);
if (err) {
this.$message.error(`Proto Verify Failed: ${err}`);
return false;
}
return type.encode(message).finish();
},
copyContent() {
return JSON.stringify(this.newContent);
},
selectProto() {
dialog.showOpenDialog({View on GitHub (pinned to c149855106)
Solutions
- Fix the JSON syntax error in the editor and save again
- Use the editor's JSON format/validate action before saving to locate the offending line
- Copy out to an external JSON linter, fix, and paste back
- Long-term: catch and surface e.message with position info so the toast names the line/column
Example fix
// before
catch (e) {
this.$message.error(this.$t('message.json_format_failed'));
return false;
}
// after - surface the parser position
catch (e) {
this.$message.error(`${this.$t('message.json_format_failed')}: ${e.message}`);
return false;
} Defensive patterns
Strategy: try-catch
Validate before calling
let parsed;
try {
parsed = JSON.parse(this.$refs.editor.getRawContent());
} catch (e) {
this.$message.error(`${this.$t('message.json_format_failed')}: ${e.message}`);
return false;
} Type guard
const isParsableJSON = (s) => {
try { JSON.parse(s); return true; } catch { return false; }
}; Try / catch
try {\n content = JSON.parse(content);\n} catch (e) {\n // abort save, keep editor state so the user can fix the text\n this.$message.error(`${this.$t('message.json_format_failed')}: ${e.message}`);\n return false;\n} Prevention
- Run the editor's JSON format action before saving to surface syntax errors with line info
- Validate on editor change (debounced) and mark invalid JSON inline
- Never paste relaxed JSON (comments/single quotes) into the editor
When it happens
Trigger: Editing the JSON in the Monaco/JsonEditor pane and introducing a syntax error (trailing comma, missing quote, unbalanced brace) then clicking save; leaving a partial edit (accidental keystroke) in the editor; pasting non-JSON text over the decoded message; JSONbig vs JSON.parse differences are not the issue here — plain JSON.parse is used at ViewerProtobuf.vue:106.
Common situations: Hand-editing long decoded messages with nested repeated fields; editor autocomplete inserting a dangling bracket; large int64 values are fine (strings), but comments or single quotes pasted from docs break parsing.
Related errors
- Proto Verify Failed: ${err}
- Raw content is an object, but now parse object failed: ${e.m
- Raw content is an object, but now parse object failed: ${e.m
- Select a correct .proto file
- Select a correct Type to encode
AI-assisted analysis of qishibo/AnotherRedisDesktopManager@c149855106 (2026-08-22).
Data as JSON: /api/errors/9f5afd82b7e56fc2.
Report an issue: GitHub.