Why java Path.Separator in JSON file format is switched to \?

I want to put a picture path in a jsonObject and pass it to javascript, in java i do

JSONObject assets = new JSONObject();

assets.put("media",PropertyLoader.getStringValue("PICTURE_DIRECTORY") + "/"+leventPhoto.getFile().getName());

When i get it in the jsp file in javascript it appears like this:

"media":"C:\/Users\/joao\/workspace\/.metadata\/.plugins\/org.eclipse.wst.server.core\/tmp1\/wtpwebapps\/RememberMeServer\/images\/02.jpg"

What can i do to make the separator appear well formated inside JSONObject displayed in javascript?

Jon Skeet
people
quotationmark

By the time the data has been read within Javascript, it will have the appropriate name. This is just an escape sequence, which doesn't change the value of the data. For example, in a Javascript console:

var x = "foo\/bar";
var y = "foo/bar";
x == y // true

I'm surprised that the forward slashes are being escaped - just "C:/Users/joao/..." would work fine - but it shouldn't make any difference to the actual value.

people

See more on this question at Stackoverflow