Ali Ali - 1 year ago 108
JSON Question

How to remove escaping special characters from json_encode output

I have some urls in my database and I want to print them as JSON using php. How can I get the desired format, without escaping backslashes, in my JSON object?

//business to get data
//print json data
echo json_encode($customer,JSON_UNESCAPED_UNICODE);

enter image description here

Answer Source

Just remove the \ you can do that using str_replace().

str_replace("\\", "", json_encode($customer,JSON_UNESCAPED_UNICODE));

Here is a link to the str_replace() function in the php manual:

Edit: I forgot to escape the backslash. It works now!

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download