title: JSON object as php string
body: <blockquote>
    <p><strong>Possible Duplicate:</strong><br>
    <a href="https://stackoverflow.com/questions/4409039/convert-a-json-into-a-utf-8-string">Convert a JSON into a UTF-8 string</a>  </p>
  </blockquote>
  
  
  
  <p>I am working on caching some twitter feeds for long term use. The result of my search yields the following type of data structure:</p>
  
  <pre><code>"results": [
  {
    "created_at": "Sun, 08 Apr 2012 18:31:04 +0000",
    "entities": {
      "hashtags": [
        {
          "text": "cheeringfor",
          "indices": [
            54,
            66
          ]
        }
      ],
      "urls": [
  
      ],
      "user_mentions": [
        {
          "screen_name": "BenSpies11",
          "name": "Ben Spies",
          "id": 32124771,
          "id_str": "32124771",
          "indices": [
            0,
            11
          ]
        }
      ]
    },...
  </code></pre>
  
  <p>I am trying to include the hashtags section of this output in my database table but I am trying to save it as plain string.</p>
  
  <p>I have tried casting it as a string i:e <code>(string)$result-&gt;hashtags</code> but I get the <strong>cannot be converted to string</strong> error. I also tried the <strong>serialize()</strong> function which worked but got php errors when I tried to un-serialize and get my object back.</p>