如何在php中从json响应中删除反斜杠

如何在php中从json响应中删除反斜杠,php,json,Php,Json,我得到的json响应如下所述: "{\"id\":\"order_DPUVoS2YVnBccy\",\"entity\":\"order\",\"amount\":100,\"amount_paid\":0,\"amount_due\":100,\"currency\":\"INR\",\"receipt\":\"7550\",\"offer_id\":null,\"status\":\"created\",\"attempts\":0,\"notes\":[],\"created_at\":1

我得到的json响应如下所述:

"{\"id\":\"order_DPUVoS2YVnBccy\",\"entity\":\"order\",\"amount\":100,\"amount_paid\":0,\"amount_due\":100,\"currency\":\"INR\",\"receipt\":\"7550\",\"offer_id\":null,\"status\":\"created\",\"attempts\":0,\"notes\":[],\"created_at\":1570082483}"
我希望输出为:

{"id":"order_DPUVoS2YVnBccy","entity":"order","amount":100,"amount_paid":0,"amount_due":100,"currency":"INR","receipt":"7550","offer_id":null,"status":"created","attempts":0,"notes":[],"created_at":1570082483}

我尝试使用
stripslashes()
删除反斜杠,但不起作用

当json解码时,您必须这样做:

$data = json_encode('yourjsonvariable'), true, JSON_UNESCAPED_SLASHES);
“不工作”是什么意思


请添加一些您试图解决此问题的代码$data=stripslashes($jsondata);echo json_编码($data)$jsondata是api调用的响应:只需回显此数据,您必须使用
json\u decode($json,true)
将json转换为数组并将其传递给foreach
json_encode()
用于将数组转换为json字符串。我希望使用php而不是Javascript输出从json中剥离斜杠后,OP在该字符串上使用
json_encode()
,这将返回斜杠:
<?php

$unescapedJson = '{\"id\":\"order_DPUVoS2YVnBccy\",\"entity\":\"order\",\"amount\":100,\"amount_paid\":0,\"amount_due\":100,\"currency\":\"INR\",\"receipt\":\"7550\",\"offer_id\":null,\"status\":\"created\",\"attempts\":0,\"notes\":[],\"created_at\":1570082483}';

echo stripslashes($unescapedJson);