title: PostgreSQL: compare jsons
body: <p>As known, at the moment PostgreSQL has no method to compare two json values. The comparison like <code>json = json</code> doesn't work. But what about casting <code>json</code> to <code>text</code> before?</p>
  
  <p>Then</p>
  
  <pre><code>select ('{"x":"a", "y":"b"}')::json::text = 
  ('{"x":"a", "y":"b"}')::json::text
  </code></pre>
  
  <p>returns <code>true</code></p>
  
  <p>while</p>
  
  <pre><code>select ('{"x":"a", "y":"b"}')::json::text = 
  ('{"x":"a", "y":"d"}')::json::text
  </code></pre>
  
  <p>returns <code>false</code></p>
  
  <p>I tried several variants with more complex objects and it works as expected.</p>
  
  <p>Are there any gotchas in this solution?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <p>The compatibility with v9.3 is needed</p>