Had some fun exploring JSON and JSONB features in PostgreSQL recently.
First task was to flatten two tables’ rows into a single field of JSON data. Nice intro to json_agg() and row_to_json().
Where it got real fun was extracting that data back out from JSON to rows & columns with the help of jsonb_path_query().