How to group by values of a json field that keys are dynamic