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

  1. Fix the JSON syntax error in the editor and save again
  2. Use the editor's JSON format/validate action before saving to locate the offending line
  3. Copy out to an external JSON linter, fix, and paste back
  4. 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

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


AI-assisted analysis of qishibo/AnotherRedisDesktopManager@c149855106 (2026-08-22). Data as JSON: /api/errors/9f5afd82b7e56fc2. Report an issue: GitHub.