Javascript 用另一个字符串替换json的字符串

Javascript 用另一个字符串替换json的字符串,javascript,json,Javascript,Json,我有一个json字符串,它是 我通过转换得到这个字符串 var json = org.cometd.JSON.toJSON(envelope.messages); "[{\"version\": \"1.0\", \"minimumVersion\": \"0.9\", \"channel\": \"/meta/handshake\", \"supportedConnectionTypes\": [\"long-polling\", \"callback-polling\"], \"advic

我有一个json字符串,它是

我通过转换得到这个字符串

var json = org.cometd.JSON.toJSON(envelope.messages);

"[{\"version\": \"1.0\", \"minimumVersion\": \"0.9\", \"channel\": \"/meta/handshake\", \"supportedConnectionTypes\": [\"long-polling\", \"callback-polling\"], \"advice\": {\"timeout\": 60000, \"interval\": 0}, \"id\": \"1\"}]"
我需要替换一些符号,我需要这样的输出

[{"version":"1.0","minimumVersion":"0.9","channel":"/meta/handshake","supportedConnectionTypes":["long-polling","callback-polling"],"advice":{"timeout":60000,"interval":0},"id":"1"}]
表示要替换的符号为
\\
”[和

如果可能的话,请帮助我

json.replace('\\', '')

字符串本身没有
“[
,只有定义字符串的

您可以简单地使用
Json.Parse()


使用javascript
replace函数

mystring.replace(/\\/g,'').replace(/" "[ "/g,'"["')

不工作:(var json=org.cometd.json.toJSON(envelope.messages);json.Parse(json);alert(json);如果你提醒它的结果,你将通过使用console.log记录它得到[object obejct'检查为什么你要提醒你的json?如果可能的话,创建你的fiddle以便我可以更新它……!!var json=org.cometd.json.toJSON(envelope.messages);JSON.Parse(JSON);_webSocket.send(JSON);this._debug('Transport',this.getType(),'sent',envelope,'metaConnect=',metaConnect);//管理等待响应的超时var maxDelay=this.getConfiguration().maxNetworkDelay;var delay=maxDelay;if(metaConnect){delay+=this.getAdvice().timeout;_connected=true;}并且在开始和结束时,我想删除“this”symbol@krishan您的具体目标是什么?将\\替换为“”,并将“[替换为[和]”替换为]
mystring.replace(/\\/g,'').replace(/" "[ "/g,'"["')