I have a table with a JSON column in Postgres, I am grouping the rows and I am looking for some aggregate function that could "sum up" values from jsons.
sum aggregator sums the integers, I am looking for equivalent aggregator for JSONs, for example these 2 JSONs:
{a: 1, b: 4}
{b: 7, c: 3}
should be aggregated to
{a: 1, b: 11, c: 3}
Note that the values in conflicting keys are summed. JSONs are always 'str->int'
Is it possible to that in Postgres? Alternatively is it possible to write a custom aggregator to do that in C?