alert('How do i make abspath==U:\\path?'); //shouldnt i only need one \?
alert(JSON.stringify({abspath:'U:\path'})); //wtf
alert(JSON.stringify({abspath:'U:\\path'}));//wtf2
//alert(JSON.stringify({abspath:'U:/path'}));//different
alert(JSON.stringify({abspath:"U:\path"})); //even here!?
alert(JSON.stringify({abspath:"U:\\path"})); //fuuuuuuuuuuuuu
Demo alert(‘How do i make abspath==U:\\path?’); //shouldnt i only need one \? alert(JSON.stringify({abspath:’U:\path’})); //wtf
Share
When the script outputs
{"abspath":"U:\\path"}, that is a valid JSON string. It doesn’t look like a valid object because it is still escaped — JSON string aren’t intended to be human-readable.If you were to decode that string, you would end up with the desired value. Your output is still escaped, as it should be, pending decoding. If it was NOT escaped in the encoded string, you wouldn’t be able to decode it.
See happen: http://jsfiddle.net/dhzMQ/1/ (requires availability of
console)Further Reading