PostgreSQL 9.3: Aggregate collection of JSON arrays
You can use json_each and LEFT JOIN LATERAL for this purpose:

WITH inventory AS (
  SELECT '{
  "category": {
    "item": ["price", "quantity"]
  },
  "widgets": {
    "foo": [300, 15],
    "bar": [500, 5],
    "baz": [400, 10]
  }
}'::text AS value
  )
SELECT
  v.key,
  (v.value-&gt;&gt;0)::INT AS price
, (v.value-&gt;&gt;1)::INT AS quantity
FROM inventory i
LEFT JOIN LATERAL json_each(i.value::JSON-&gt;$1) v ON (true)
WHERE as_of_date = $3::DATE;


You can then filter, group by and sum as you need.