{"record":{"id":"9f5afd82b7e56fc2","repo":"qishibo/AnotherRedisDesktopManager","slug":"this-t-message-json-format-failed-9f5afd","errorCode":null,"errorMessage":"this.$t('message.json_format_failed')","messagePattern":"this\\.\\$t\\('message\\.json_format_failed'\\)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/components/viewers/ViewerProtobuf.vue","lineNumber":109,"sourceCode":"  methods: {\n    getContent() {\n      if (!this.protoRoot) {\n        this.$message.error('Select a correct .proto file');\n        return false;\n      }\n\n      if (!this.selectedType || this.selectedType === 'Rawproto') {\n        this.$message.error('Select a correct Type to encode');\n        return false;\n      }\n\n      let content = this.$refs.editor.getRawContent();\n      const type = this.protoRoot.lookupType(this.selectedType);\n\n      try {\n        content = JSON.parse(content);\n      } catch (e) {\n        this.$message.error(this.$t('message.json_format_failed'));\n        return false;\n      }\n\n      // toJSON() shows int64/uint64 as strings; fromObject converts them back\n      const message = type.fromObject(content);\n      const err = type.verify(message);\n      if (err) {\n        this.$message.error(`Proto Verify Failed: ${err}`);\n        return false;\n      }\n\n      return type.encode(message).finish();\n    },\n    copyContent() {\n      return JSON.stringify(this.newContent);\n    },\n    selectProto() {\n      dialog.showOpenDialog({","sourceCodeStart":91,"sourceCodeEnd":127,"githubUrl":"https://github.com/qishibo/AnotherRedisDesktopManager/blob/c149855106628babcdfb7675a8e7ba9434d2492a/src/components/viewers/ViewerProtobuf.vue#L91-L127","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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"],"exampleFix":"// before\ncatch (e) {\n  this.$message.error(this.$t('message.json_format_failed'));\n  return false;\n}\n\n// after - surface the parser position\ncatch (e) {\n  this.$message.error(`${this.$t('message.json_format_failed')}: ${e.message}`);\n  return false;\n}","handlingStrategy":"try-catch","validationCode":"let parsed;\ntry {\n  parsed = JSON.parse(this.$refs.editor.getRawContent());\n} catch (e) {\n  this.$message.error(`${this.$t('message.json_format_failed')}: ${e.message}`);\n  return false;\n}","typeGuard":"const isParsableJSON = (s) => {\n  try { JSON.parse(s); return true; } catch { return false; }\n};","tryCatchPattern":"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}","preventionTips":["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"],"tags":["json","protobuf","vue","user-input"],"backgroundTag":"json-parse-error","analyzedSha":"c149855106628babcdfb7675a8e7ba9434d2492a","analyzedAt":"2026-08-22T09:06:28.613Z","schemaVersion":2},"datasetVersion":"2026-08-22T09:17:25.309Z"}