qishibo/AnotherRedisDesktopManager · error
this.$t('message.json_format_failed')
Error message
this.$t('message.json_format_failed') What it means
Not a thrown exception but an app-level guard: getContent() validates the Monaco editor buffer with $util.isJson before parsing; invalid content blocks the save with a localized message and returns false. The underlying family is JSON.parse throwing SyntaxError (Unexpected token ... in JSON at position N) on unbalanced braces, single-quoted strings, trailing commas, or truncated documents.
Source
Thrown at src/components/JsonEditor.vue:57
}
return JSONbig.stringify(this.content, null, 4);
},
},
watch: {
// refresh
content() {
this.$nextTick(() => {
this.monacoEditor.setValue(this.newContentStr);
});
},
},
methods: {
getContent() {
const content = this.monacoEditor.getValue();
if (!this.$util.isJson(content)) {
this.$message.error(this.$t('message.json_format_failed'));
return false;
}
return Buffer.from(JSONbig.stringify(JSONbig.parse(content), null, 0));
},
getRawContent(removeJsonSpace = false) {
let content = this.monacoEditor.getValue();
if (removeJsonSpace) {
if (this.$util.isJson(content)) {
content = JSONbig.stringify(JSONbig.parse(content), null, 0);
}
}
return content;
},
toggleCollapse() {
this.collapseText == 'expand_all' ? this.monacoEditor.trigger('fold', 'editor.unfoldAll')View on GitHub (pinned to c149855106)
Solutions
- Fix the syntax at the position the parser reports, or run the buffer through a JSON formatter/validator before saving
- Remove JS-only syntax: single quotes, trailing commas, comments, unquoted keys
- Trim surrounding whitespace/BOM or any plain-text wrapper around the JSON document
- Keep numbers JSONbig-compatible so formatting round-trips do not corrupt the document
Defensive patterns
Strategy: validation
Validate before calling
const content = this.monacoEditor.getValue();
if (!isJsonValid(content)) {
this.$message.error(this.$t('message.json_format_failed'));
return false;
} Type guard
function isJsonValid(s) {
if (typeof s !== 'string' || !s.trim()) return false;
try { JSONbig.parse(s); return true; } catch { return false; }
} Prevention
- Validate before parse; never parse editor content blind
- Wire Monaco's format action to a keybinding so users can auto-fix
- Show the parser's reported position so the cursor can jump to the fault
When it happens
Trigger: Saving a string key edited as JSON with incomplete syntax (unclosed brace/bracket); single-quoted keys or trailing commas pasted from JS; a concatenated or partially edited JSON document; stray BOM/whitespace wrapping the JSON text.
Common situations: Editing API-cache or config values stored as JSON, pasting from JS/Python sources with non-JSON syntax, partial edits while auto-format is off, big-number documents edited by hand (this app uses JSONbig).
Related errors
- this.$t('message.json_format_failed')
- this.$t('message.json_format_failed')
- Attributes must be valid JSON
- this.$t('message.json_format_failed')
- Raw content is an object, but now parse object failed: ${e.m
AI-assisted analysis of qishibo/AnotherRedisDesktopManager@c149855106 (2026-08-22).
Data as JSON: /api/errors/85e395cff26bc5b9.
Report an issue: GitHub.