如何把json对象格式化成"[{\"id\":\"669\",\"sales_id\":\"CRM\"}]"?

我通过下列方法无法得到

JSON.stringify({
        "crmUserId": "CRMc94fe64bd7db473086b9e7f2bea27",
        "userName": "Sophie Liang",
        "extValues": {}
      })
'{"crmUserId":"CRMc94fe64bd7db473086b9e7f2bea27","userName":"Sophie Liang","extValues":{}}'
JSON.stringify(JSON.stringify({
        "crmUserId": "CRMc94fe64bd7db473086b9e7f2bea27",
        "userName": "Sophie Liang",
        "extValues": {}
      }))
'"{\\"crmUserId\\":\\"CRMc94fe64bd7db473086b9e7f2bea27\\",\\"userName\\":\\"Sophie Liang\\",\\"extValues\\":{}}"'
阅读 1.8k
2 个回答
新手上路,请多包涵

const x=JSON.stringify([{"crmUserId": "CRMc94fe64bd7db473086b9e7f2bea27","userName": "Sophie Liang","extValues": {}}])
console.log(x)
输出[{"crmUserId":"CRMc94fe64bd7db473086b9e7f2bea27","userName":"Sophie Liang","extValues":{}}]

有没有一种可能 "\"" 就是 '"',还是你真的要字符串里有斜杠?

推荐问题