Escape json in javascript
Clash Royale CLAN TAG #URR8PPP Escape json in javascript Need to escape the following json { "xx": 'a', "yy": "bb" } into the following structure in javascript {rnt"xx": 'a',rnt"yy": "bb"rn} I have tried the code suggestion from this link, How to escape a JSON string containing newline characters using JavaScript? var request = { "xx": "aaa", "yy": "bb" } var myJSONString = JSON.stringify(request); var myEscapedJSONString = myJSONString.replace(/\n/g, "\n").replace(/\'/g, "\'").replace(/\"/g, '\"').replace(/\&/g, "\&").replace(/\r/g, "\r").replace(/\t/g, "\t").replace(/\b/g, "\b").replace(/\f/g, "\f"); but not worked, please help. Code has to escape like the following Where is your attempted code? – Mamun ...