2013-11-22 24 views
0

我在将json格式的字符串转换为json对象时遇到了问题。 我正在使用ajax保存将json字符串保存到数据库中。我想将字符串转换为json进行进一步操作。我用json_decode但没有帮助。如何将保存在mysql数据库中的json字符串转换为php JSON对象

JSON字符串在MySQL数据库:

"{\"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的选择得到这个领域。我想要做的是将字符串转换为JSON对象。

回答

3

尝试json_decode()一样,

$array=json_decode($yourjson,true); 
var_dump($array); 

Object

$object=json_decode($yourjson); 
var_dump($object); 
+0

感谢罗汉是做了trick.But时,我想这不分配给像$阵列它没有表现出奇怪的变量..无论如何快速回复...真的很感谢朋友! :) –

相关问题