title: PostgreSQL Nested JSON Querying
body: <p>On PostgreSQL 9.3.4, I have a JSON type column called "person" and the data stored in it is in the format <code>{dogs: [{breed: &lt;&gt;, name: &lt;&gt;}, {breed: &lt;&gt;, name: &lt;&gt;}]}</code>.  I want to retrieve the breed of dog at index 0.  Here are the two queries I ran:</p>
  
  <p><strong>Doesn't work</strong></p>
  
  <pre><code>db=&gt; select person-&gt;'dogs'-&gt;&gt;0-&gt;'breed' from people where id = 77;
  ERROR:  operator does not exist: text -&gt; unknown
  LINE 1: select person-&gt;'dogs'-&gt;&gt;0-&gt;'bree...
                                   ^
  HINT:  No operator matches the given name and argument type(s). You might need to add explicit type casts.
  </code></pre>
  
  <p><strong>Works</strong></p>
  
  <pre><code>select (person-&gt;'dogs'-&gt;&gt;0)::json-&gt;'breed' from es_config_app_solutiondraft where id = 77;
   ?column?
  -----------
   "westie"
  (1 row)
  </code></pre>
  
  <p>Why is the type casting necessary?  Isn't it inefficient?  Am I doing something wrong or is this necessary for postgres JSON support?</p>