Sum of JSON values
<p>Is there a nicer way to sum JSON values in PostgreSQL:</p>

<pre><code>SELECT SUM(j.value::int)
  FROM json_each_text('{"a": 1, "b": 2}'::json) AS j(_, value);

 sum
-----
  3
</code></pre>