> The bigger picture here, though, is what are you really buying compared to just invoking the special conversion function explicitly? > If you have to write "sometsrangecolumn::mytsrange::json", that's not shorter and certainly not clearer than writing a function call.
The main benefit is to be able to call `json_agg` on tables with these custom json representations. Then the defined json casts work transparently when doing: select json_agg(x) from mytbl x; json_agg ------------------------------------------------------------------------------------------------------------------------------- [{"id":1,"val":{"lower" : "2022-12-31T11:00:00", "upper" : "2023-01-01T06:00:00", "lower_inc" : false, "upper_inc" : false}}] -- example table create table mytbl(id int, val mytsrange); insert into mytbl values (1, '(2022-12-31 11:00, 2023-01-01 06:00)'); This output is directly consumable on web applications and as you can see the expression is pretty short, with no need to use the explicit casts as `json_agg` already does them internally. Best regards, Steve