javascript - 如何从 axios post 请求中的 json 中删除反斜杠

标签 javascript json vue.js vuejs2 axios

发送 axios post 请求时向 json 文件添加反斜杠。即使我使用替换,反斜杠也不会被删除

 axios
      .post(
        "https://test-manager/backend",
        {
          gameName: this.gameName,
          platform: this.gamePlatform,
          json: finalData.replace(/\\/g, ""),
        }
      )
      .then(function (response) {
        console.log(response);
      })
      .catch(function (error) {
        console.log(error);
      });

enter image description here

最佳答案

您需要使用 JSON.parse 解析字符串化的 json,如下所示:

json: JSON.parse(finalData),

关于javascript - 如何从 axios post 请求中的 json 中删除反斜杠,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69966117/

相关文章:

javascript - 预加载图像时 Internet Explorer 循环错误

javascript - jQuery 显示和隐藏动态类不起作用

javascript - firebase.auth.signInWithCustomToken 不是函数node.js

javascript - 从 JSON 检索数据时 HTML 图像未正确对齐

javascript - Vue 方法无法在其他方法内部工作

javascript - ES6 通过字符串值调用类方法

mysql - 我如何显示 json 对象 {"id":"value"} 而不是 {"col1":"id","col2:"值"}

android - 单个数组的JSON解析和数组名

vue.js - 在其他vue组件文件中使用vue组件

vue.js - 如何转义vuejs中的内容?