我有JSON,它已保存在我网站的文本框中,并保存到下面的数据库中。
{"@type":"GOOOGLE.COM","@id":"GOOGLE","url":"GOOGLE","inLanguage":"en-US","name":"dfghjk | Bloomberg Professional Services","isPartOf":{"@id":"GOOGLE,"datePublished":"2020-02-11T21:51:45+00:00","dateModified":"2020-02-11T21:51:45+00:00"}]}
我想将其转换为PHP中的正确外观,如下所示:
{"@type":"GOOOGLE.COM","@id":"GOOGLE","url":"GOOGLE","inLanguage":"en-US","name":"dfghjk | Bloomberg Professional Services","isPartOf":{"@id":"GOOGLE,"datePublished":"2020-02-11T21:51:45+00:00","dateModified":"2020-02-11T21:51:45+00:00"}]}
我试着做了一个json_encode但它不起作用。如何将带有所有这些转义引号等的字符串转换为PHP中的普通json字符串?
我试过这样:
$str = "{"@type":"GOOOGLE.COM","@id":"GOOGLE","url":"GOOGLE","inLanguage":"en-US","name":"dfghjk | Bloomberg Professional Services","isPartOf":{"@id":"GOOGLE,"datePublished":"2020-02-11T21:51:45+00:00","dateModified":"2020-02-11T21:51:45+00:00"}]}"
$data = json_encode($str, true);
return $data;
一只名叫tom的猫