Strip Slashes from JSON object


I have the following data,

var data = {"\id\":"\23232\","\pass\":"\1434\"}

All i want to do is to strip the backslashes. Javascript’s replace function doesn’t work.

var outputData = {"id":"23232","pass":"1434"}

Any Help?


I think this link little help remove strip tag slashes


Don’t get me wrong but this is the Ionic Framework forum.

This question should be asked at StackOverflow.

P.S. Like @junaidy told you use Regular Expressions. Learn them if you don’t know then, you can’t call yourself a developer if you don’t know how to use Regex.


oh sorry but this is may be help, and you only convert to json again

    var data = {"\\id\\":"\\23232\\","\\pass\\":"\\1434\\"};
    var b=JSON.stringify(data);
    str = b.replace(/\\/g, '');


Nice, simplest solutions are best. I would only put it all in a single line.