如何从JSON PHP编写的文件中删除反斜杠

如何从JSON PHP编写的文件中删除反斜杠,php,json,Php,Json,我的脚本正在生成一个JSON文件,该文件应如下所示: [{"activeSheetIndex":0,"sheetCount":1,"tabStripRatio":0.5,"tabStripVisible":true,"tabEditable":true,"newTabVisible":true,"referenceStyle":0, 但就像: {\"activeSheetIndex\":0,\"sheetCount\":1,\"tabStripRatio\":0.5,\"tabStripVis

我的脚本正在生成一个JSON文件,该文件应如下所示:

[{"activeSheetIndex":0,"sheetCount":1,"tabStripRatio":0.5,"tabStripVisible":true,"tabEditable":true,"newTabVisible":true,"referenceStyle":0,
但就像:

{\"activeSheetIndex\":0,\"sheetCount\":1,\"tabStripRatio\":0.5,\"tabStripVisible\":true,\"tabEditable\":true,\"newTabVisible\":true,\"referenceStyle\":0,
我怎样才能去掉那些反斜杠

我尝试了str_replace,但它不起作用:

$myFile = $diretorio."/dados.json";
$fh = fopen($myFile, 'w') or die("não é possível abrir o ficheiro");

$stringData = $_POST['data'];
$stringData= str_replace('\\/', '', $stringData);   
fwrite($fh, $stringData);
fclose($fh);

什么是
var_dump(get_magic_quotes_gpc())输出?尝试执行json_编码($\u POST['data']),并查看结果HP的
json_encode()
函数为您提供的输入数据生成有效的json字符串。不要试图在JSON字符串生成后更改它;只需修复输入数据。json_encode()实际上会产生3个反斜杠,而不是1个。你的dados.json看起来像什么?