我在php中将json格式的字符串转换为json对象时遇到问题。我正在使用ajax保存将一个json字符串保存到数据库中。我想将字符串转换为json,以便进行进一步的操作。我使用了json_decode,但没有任何帮助。
MYSQL数据库中的JSON字符串:
"{'"title'":'"Sachin vs shoaib akhtar and company..Unseen (BAAP BAAP HI HOTA HAI ) ....flv'",'"titleEsc'":'"Sachin vs shoaib akhtar and company..Unseen (BAAP BAAP HI HOTA HAI ) ....flv'",'"url'":'"http://www.youtube.com/watch?v=WOJlDpoL7tw'",'"pageUrl'":'"http://www.youtube.com/watch?v=WOJlDpoL7tw'",'"cannonicalUrl'":'"www.youtube.com'",'"description'":'"Sachin hitting cluless shoaib akhtar and company everywhere in ground..This is one f many innings where shoaib akhtar was brutually assaulted by sachin tendu...'",'"descriptionEsc'":'"Sachin hitting cluless shoaib akhtar and company everywhere in ground..This is one f many innings where shoaib akhtar was brutually assaulted by sachin tendu...'",'"images'":'"http://i2.ytimg.com/vi/WOJlDpoL7tw/hqdefault.jpg'",'"video'":'"yes'",'"videoIframe'":'"<iframe id='''"20131122120255WOJlDpoL7tw'''" style='''"display: none; margin-bottom: 5px;'''" width='''"499'''" height='''"368'''" src='''"http://www.youtube.com/embed/WOJlDpoL7tw'''" frameborder='''"0'''" allowfullscreen></iframe>'"}"
我是通过mysql-select得到这个字段的。我想做的是将字符串转换为JSON对象。
尝试json_decode()类,
$array=json_decode($yourjson,true);
var_dump($array);
对于Object
$object=json_decode($yourjson);
var_dump($object);