title: php json_encode
body: <p>I have a symfony app that uses the <code>json_encode</code> and <code>json_decode</code> to keep a record of some prices.
  The problem is that <code>json_decode</code> works OK in one file (I can decode the string stored in my PSQL database), but when I call it from other file <code>json_decode</code> returns null, I've check the file encodings (all are utf-8) the tables and database encoding(utf-8 too). So I don't know where the problem can be, tried <code>utf8_encode()</code> too...</p>
  
  <p>Any help will be appreciated.
  Thanks.</p>
  
  <p>Here's the valid encoded json (It was an array encoded by php json_encode)</p>
  
  <pre><code>{"1":{"1":{"fechaInicio":"30-05-2011","precios":{"1":{"precio":"20000","abreviatura":"CLP"}},"fechaRetiro":"31-05-2011"}},"2":{"2":{"fechaInicio":"30-05-2011","precios":{"1":{"precio":"20000","abreviatura":"CLP"}},"fechaRetiro":"31-05-2011"}}}
  </code></pre>
  
  <p>The array: </p>
  
  <pre><code>$preciosOfertor = Array ( [unidades] =&gt; Array ( [1] =&gt; Array ( [1] =&gt; Array ( [fechaInicio] =&gt; 30-05-2011 [precios] =&gt; Array ( [1] =&gt; Array ( [precio] =&gt; 20000 [abreviatura] =&gt; CLP ) ) [fechaRetiro] =&gt; 31-05-2011 ) ) [2] =&gt; Array ( [2] =&gt; Array ( [fechaInicio] =&gt; 30-05-2011 [precios] =&gt; Array ( [1] =&gt; Array ( [precio] =&gt; 20000 [abreviatura] =&gt; CLP ) ) [fechaRetiro] =&gt; 31-05-2011 ) ) ) ) 
  </code></pre>
  
  <p>To encode it I use:</p>
  
  <pre><code>$preciosOfertor = json_encode($preciosOfertor); 
  </code></pre>
  
  <p>Then I call </p>
  
  <pre><code>$precios = json_decode($databaseObject-&gt;getPreciosOfertor(),true); 
  </code></pre>
  
  <p>When i use json_decode in the file that encodes the array it works, but then when I use it in other file of the project I just get NULL with var_dump().</p>
  
  <p>Installed Services_JSON as suggested, but now I'm getting an empty array</p>
  
  <p>The encoded json with Services_JSON is this one: </p>
  
  <pre><code>{"unidades":{"1":{"1":{"fechaInicio":"30-05-2011","precios":{"1":{"precio":"20000","abreviatura":"CLP"}},"fechaRetiro":"31-05-2011"}}}}
  </code></pre>
  
  <p>But when I call $json->decode() I get Array ( )</p>