Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

I have an issue with converting a string in json format to json object in php. I am saving a json string into database using ajax save. I want to convert the string into json for doing further operation. I used json_decode but with no help.

JSON STRING IN MYSQL DATABASE:

"{\"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>\"}"

I am getting this field through mysql select. What i want to do is convert the string into JSON Object.

share|improve this question

1 Answer 1

up vote 2 down vote accepted

Try json_decode() like,

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

For Object

$object=json_decode($yourjson);
var_dump($object);
share|improve this answer
    
thanks Rohan that did the trick.But when i tried this without assigning to a variable like $array it was not showing strange... anyway fast reply...really appreciate buddy!! :) –  George Joffin Joy Nov 22 '13 at 7:11

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.