I have a simple JSON on which I would like to replace one string from one property. Let's say this is my JSON :
var values = [
{ id: 10, url: "www.mydomainname.com/images\uploads\xfolder\FILE_NAME.JPG", longitude: 121.256248, latitude: 19347774275 },
{ id: 11, url: "www.mydomainname.com/images\uploads\xfolder\FILE_NAME.JPG", longitude: 121.7534025, latitude: 19347868 },
{ id: 12, url: "www.mydomainname.com/images\uploads\xfolder\FILE_NAME.JPG", longitude: 121.85458, latitude: 1934748775 },
{ id: 13, url: "www.mydomainname.com/images\uploads\xfolder\FILE_NAME.JPG", longitude: 121.5525, latitude: 19317868 }
]
Now what I would like to do is to replace every \ with a slash / . For example :
from url: www.mydomainname.com/images\uploads\xfolder\FILE_NAME.JPG
to url: www.mydomainname.com/images/uploads/xfolder/FILE_NAME.JPG
What I tried was very simple. This is what I tried :
for(i = 0; i < values.length; i++){
var str = values[i].url;
var res = str.replace("''\''", "/");
}
But it didn't work. Any help would be highly appreciated, since it's been a while I've been stucked Thanks in advance :)
"''\''"you'll want a regex for the search value for a start ...values[i].url = values[i].url.replace(/\\/g, '/')