简体   繁体   English

如何使用php删除json URL中的反斜杠

[英]how to remove backslashes in json URL with php

i need to remove () backslash in my string when using echo json_encode() ? 使用echo json_encode()时,我需要删除字符串中的()反斜杠吗?

my example.. 我的例子

$song_url = 116e9155e0afc11555cf33dc9c9bd25d.mp3
$resmsg[] = array("Song_name"=>"$song_name","Song_URL"=>"http://www.kbmusique.com/songs/$song_url");
echo json_encode($resmsg);

my output is 我的输出是

 [{"Song_name":"djigh araouioui","Song_URL":"http:\/\/www.kbmusique.com\/songs\/116e9155e0afc11555cf33dc9c9bd25d.mp3"}]

but i need as 但我需要

 [{"Song_name":"djigh araouioui","Song_URL":"http://www.kbmusique.com/songs/116e9155e0afc11555cf33dc9c9bd25d.mp3"}]

Is there a way to solve this? 有办法解决吗? Thank you. 谢谢。

Your comment indicates that you just need to get a copy/pastable URL for testing. 您的评论表明您只需要获取一个可复制/可粘贴的URL即可进行测试。

Just parse the JSON and extract the piece of data you need from it. 只需解析JSON并从中提取所需的数据即可。 ie If you want a text representation of something, then convert the JSON to text, don't try to hack the JSON into a specific form. 即,如果您想要某种东西的文本表示形式,然后将JSON转换为文本,请不要尝试将JSON修改为特定形式。

You could do this in PHP with json_decode , in a browser with JSON.parse() , or just use a tool such as the Chrome JSONView extension . 您可以在PHP中使用json_decode或在具有JSON.parse()的浏览器中执行此操作,也可以仅使用Chrome JSONView扩展程序之类的工具。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM